aboutsummaryrefslogtreecommitdiffstats
path: root/src/sigs.c
diff options
context:
space:
mode:
authorLars Henriksen <LarsHenriksen@get2net.dk>2020-07-14 09:07:00 +0200
committerLukas Fleischer <lfleischer@calcurse.org>2020-07-26 10:31:28 -0400
commitf743eab5ac96314044fe748f0f1875a1ee78d3a9 (patch)
treeade004dff23390840584fb768fca536fcc6f056c /src/sigs.c
parent41e1a89aa73877d3477595b7425ac7c2ab65a573 (diff)
downloadcalcurse-f743eab5ac96314044fe748f0f1875a1ee78d3a9.tar.gz
calcurse-f743eab5ac96314044fe748f0f1875a1ee78d3a9.zip
Remove SIGCHLD signal handler
The purpose is to make child_wait() reliable. The handler is meant for the notify main thread, but signal handlers are shared by all threads. In the calcurse main thread and the periodic save thread (hooks) the handler and child_wait() will compete (if the signal handler kicks in first, the waitpid() call in child_wait() will fail with errno ECHILD). All child processes in the main thread, the notify thread, the periodic save thread and the notify demon are explicitly waited for. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/sigs.c')
-rw-r--r--src/sigs.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/sigs.c b/src/sigs.c
index 02457ae..fab4498 100644
--- a/src/sigs.c
+++ b/src/sigs.c
@@ -68,27 +68,18 @@
/*
* General signal handling routine.
- * Catch return values from children (user-defined notification commands).
- * This is needed to avoid zombie processes running on system.
- * Also catch CTRL-C (SIGINT), and SIGWINCH to resize screen automatically.
+ * Catch SIGWINCH to resize screen automatically.
*/
static void generic_hdlr(int sig)
{
switch (sig) {
- case SIGCHLD:
- while (waitpid(WAIT_MYPGRP, NULL, WNOHANG) > 0) ;
- break;
case SIGWINCH:
resize = 1;
clearok(curscr, TRUE);
ungetch(KEY_RESIZE);
break;
case SIGTERM:
- if (unlink(path_cpid) != 0) {
- EXIT(_("Could not remove calcurse lock file: %s\n"),
- strerror(errno));
- }
- exit(EXIT_SUCCESS);
+ exit_calcurse(EXIT_SUCCESS);
break;
case SIGUSR1:
want_reload = 1;
@@ -117,12 +108,11 @@ unsigned sigs_set_hdlr(int sig, void (*handler) (int))
/* Signal handling init. */
void sigs_init()
{
- if (!sigs_set_hdlr(SIGCHLD, generic_hdlr)
- || !sigs_set_hdlr(SIGWINCH, generic_hdlr)
+ if (!sigs_set_hdlr(SIGWINCH, generic_hdlr)
|| !sigs_set_hdlr(SIGTERM, generic_hdlr)
|| !sigs_set_hdlr(SIGUSR1, generic_hdlr)
|| !sigs_set_hdlr(SIGINT, SIG_IGN))
- exit_calcurse(1);
+ exit_calcurse(EXIT_FAILURE);
}
/* Ignore SIGWINCH and SIGTERM signals. */