diff options
author | Lars Henriksen <LarsHenriksen@get2net.dk> | 2020-07-14 09:07:00 +0200 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2020-07-26 10:31:28 -0400 |
commit | f743eab5ac96314044fe748f0f1875a1ee78d3a9 (patch) | |
tree | ade004dff23390840584fb768fca536fcc6f056c /src/utils.c | |
parent | 41e1a89aa73877d3477595b7425ac7c2ab65a573 (diff) | |
download | calcurse-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/utils.c')
-rw-r--r-- | src/utils.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/utils.c b/src/utils.c index 0a98ce0..2d2f615 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1425,8 +1425,10 @@ int child_wait(int *pfdin, int *pfdout, int pid) if (pfdout) close(*pfdout); - waitpid(pid, &stat, 0); - return stat; + if (waitpid(pid, &stat, 0) == pid) + return stat; + else + return -1; } /* Display "Press any key to continue..." and wait for a key press. */ |