close signal_fd in cleanup
We should close file descriptors that we open. Also this commit adds handling SIGINT (same as SIGTERM) and does not die if we got EAGAIN from poll().
This commit is contained in:
parent
6078a20af4
commit
e6eb713fb3
1 changed files with 7 additions and 2 deletions
9
dam.c
9
dam.c
|
@ -727,6 +727,7 @@ setup(void)
|
||||||
sigemptyset(&mask);
|
sigemptyset(&mask);
|
||||||
sigaddset(&mask, SIGUSR1);
|
sigaddset(&mask, SIGUSR1);
|
||||||
sigaddset(&mask, SIGTERM);
|
sigaddset(&mask, SIGTERM);
|
||||||
|
sigaddset(&mask, SIGINT);
|
||||||
|
|
||||||
if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0)
|
if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0)
|
||||||
die("sigprocmask:");
|
die("sigprocmask:");
|
||||||
|
@ -758,7 +759,9 @@ run(void)
|
||||||
if (wl_display_flush(display) < 0)
|
if (wl_display_flush(display) < 0)
|
||||||
die("wl_display_flush:");
|
die("wl_display_flush:");
|
||||||
|
|
||||||
if (poll(pfds, 3, -1) < 0) {
|
while (poll(pfds, 3, -1) < 0) {
|
||||||
|
if (errno == EAGAIN)
|
||||||
|
continue;
|
||||||
wl_display_cancel_read(display);
|
wl_display_cancel_read(display);
|
||||||
die("poll:");
|
die("poll:");
|
||||||
}
|
}
|
||||||
|
@ -778,7 +781,8 @@ run(void)
|
||||||
die("signalfd/read:");
|
die("signalfd/read:");
|
||||||
if (si.ssi_signo == SIGUSR1)
|
if (si.ssi_signo == SIGUSR1)
|
||||||
bars_toggle_selected();
|
bars_toggle_selected();
|
||||||
else if (si.ssi_signo == SIGTERM)
|
else if (si.ssi_signo == SIGTERM ||
|
||||||
|
si.ssi_signo == SIGINT)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -814,6 +818,7 @@ cleanup(void)
|
||||||
wl_compositor_destroy(compositor);
|
wl_compositor_destroy(compositor);
|
||||||
wl_registry_destroy(registry);
|
wl_registry_destroy(registry);
|
||||||
wl_display_disconnect(display);
|
wl_display_disconnect(display);
|
||||||
|
close(signal_fd); /* ignore error */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Add table
Reference in a new issue