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>
This commit is contained in:
Lars Henriksen
2020-07-14 09:07:00 +02:00
committed by Lukas Fleischer
parent 41e1a89aa7
commit f743eab5ac
4 changed files with 17 additions and 19 deletions

View File

@@ -34,6 +34,7 @@
*
*/
#include <sys/wait.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
@@ -358,6 +359,9 @@ static void *notify_main_thread(void *arg)
pthread_mutex_unlock(&notify.mutex);
notify_update_bar();
psleep(thread_sleep);
/* Reap the user-defined notifications. */
while (waitpid(0, NULL, WNOHANG) > 0)
;
elapse += thread_sleep;
if (elapse >= check_app) {
elapse = 0;