aboutsummaryrefslogtreecommitdiffstats
path: root/src/dmon.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/dmon.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/dmon.c')
-rw-r--r--src/dmon.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/dmon.c b/src/dmon.c
index f9bbfd2..e61caf5 100644
--- a/src/dmon.c
+++ b/src/dmon.c
@@ -34,7 +34,7 @@
*
*/
-#include <sys/types.h>
+#include <sys/wait.h>
#include <sys/stat.h>
#include <unistd.h>
#include <paths.h>
@@ -143,8 +143,7 @@ static unsigned daemonize(int status)
|| !sigs_set_hdlr(SIGTERM, dmon_sigs_hdlr)
|| !sigs_set_hdlr(SIGALRM, dmon_sigs_hdlr)
|| !sigs_set_hdlr(SIGQUIT, dmon_sigs_hdlr)
- || !sigs_set_hdlr(SIGUSR1, dmon_sigs_hdlr)
- || !sigs_set_hdlr(SIGCHLD, SIG_IGN))
+ || !sigs_set_hdlr(SIGUSR1, dmon_sigs_hdlr))
return 0;
return 1;
@@ -203,6 +202,9 @@ void dmon_start(int parent_exit_status)
DMON_SLEEP_TIME);
psleep(DMON_SLEEP_TIME);
DMON_LOG(_("awakened at %s\n"), nowstr());
+ /* Reap the user-defined notifications. */
+ while (waitpid(0, NULL, WNOHANG) > 0)
+ ;
}
}