summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-07-17 17:31:44 +0200
committerDaniel Friesel <derf@finalrewind.org>2018-07-17 17:31:44 +0200
commit3ca93e4f99cd3fc6a7d51cf13ead619d4587da70 (patch)
tree9cb90fdd58baaa81402ca7b2a7165d72dbfc9e10
parent946c837a9fe78737020ae0d3a7f1b2e7201ae3ff (diff)
parentf428edbd1945e9464896fa65c795563ca346d47f (diff)
Merge branch 'giladogit-patch-1'
-rw-r--r--src/main.c12
-rw-r--r--src/signals.c4
-rw-r--r--src/signals.h2
3 files changed, 10 insertions, 8 deletions
diff --git a/src/main.c b/src/main.c
index f1fca24..1a76e2d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -87,7 +87,7 @@ int main(int argc, char **argv)
/* main event loop */
while (feh_main_iteration(1));
- return(0);
+ return(sig_exit);
}
/* Return 0 to stop iterating, 1 if ok to continue. */
@@ -104,7 +104,7 @@ int feh_main_iteration(int block)
double t1 = 0.0, t2 = 0.0;
fehtimer ft;
- if (window_num == 0)
+ if (window_num == 0 || sig_exit != 0)
return(0);
if (first) {
@@ -137,7 +137,7 @@ int feh_main_iteration(int block)
if (ev_handler[ev.type])
(*(ev_handler[ev.type])) (&ev);
- if (window_num == 0)
+ if (window_num == 0 || sig_exit != 0)
return(0);
}
XFlush(disp);
@@ -191,7 +191,7 @@ int feh_main_iteration(int block)
in that */
feh_handle_timer();
}
- else if (count && (FD_ISSET(0, &fdset)))
+ else if ((count > 0) && (FD_ISSET(0, &fdset)))
feh_event_handle_stdin();
}
} else {
@@ -204,11 +204,11 @@ int feh_main_iteration(int block)
&& ((errno == ENOMEM) || (errno == EINVAL)
|| (errno == EBADF)))
eprintf("Connection to X display lost");
- else if (count && (FD_ISSET(0, &fdset)))
+ else if ((count > 0) && (FD_ISSET(0, &fdset)))
feh_event_handle_stdin();
}
}
- if (window_num == 0)
+ if (window_num == 0 || sig_exit != 0)
return(0);
return(1);
diff --git a/src/signals.c b/src/signals.c
index c08d5df..aeaf889 100644
--- a/src/signals.c
+++ b/src/signals.c
@@ -28,6 +28,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "options.h"
void feh_handle_signal(int);
+int sig_exit = 0;
void setup_signal_handlers()
{
@@ -86,7 +87,8 @@ void feh_handle_signal(int signo)
case SIGQUIT:
if (childpid)
killpg(childpid, SIGINT);
- exit(128 + signo);
+ sig_exit = 128 + signo;
+ return;
}
winwid = winwidget_get_first_window_of_type(WIN_TYPE_SLIDESHOW);
diff --git a/src/signals.h b/src/signals.h
index 526285d..090ab0b 100644
--- a/src/signals.h
+++ b/src/signals.h
@@ -27,5 +27,5 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define SIGNALS_H
void setup_signal_handlers();
-
+extern int sig_exit;
#endif