From: Stephan Bosch Date: Thu, 21 Feb 2019 01:37:41 +0000 (+0100) Subject: lib: child-wait - Mark the SIGCHLD handler as expected when waiting for child. X-Git-Tag: 2.3.13~657 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=be38004f75de5e936b5a0e0f025b1d38866098d2;p=thirdparty%2Fdovecot%2Fcore.git lib: child-wait - Mark the SIGCHLD handler as expected when waiting for child. This alows waiting for a child to be the only activity on the ioloop. --- diff --git a/src/lib/child-wait.c b/src/lib/child-wait.c index bba43a3dec..90f8ec545f 100644 --- a/src/lib/child-wait.c +++ b/src/lib/child-wait.c @@ -19,6 +19,9 @@ static int child_wait_refcount = 0; /* pid_t => wait */ static HASH_TABLE(void *, struct child_wait *) child_pids; +static void +sigchld_handler(const siginfo_t *si ATTR_UNUSED, void *context ATTR_UNUSED); + #undef child_wait_new_with_pid struct child_wait * child_wait_new_with_pid(pid_t pid, child_wait_callback_t *callback, @@ -64,12 +67,17 @@ void child_wait_add_pid(struct child_wait *wait, pid_t pid) { wait->pid_count++; hash_table_insert(child_pids, POINTER_CAST(pid), wait); + + lib_signals_set_expected(SIGCHLD, TRUE, sigchld_handler, NULL); } void child_wait_remove_pid(struct child_wait *wait, pid_t pid) { wait->pid_count--; hash_table_remove(child_pids, POINTER_CAST(pid)); + + if (hash_table_count(child_pids) == 0) + lib_signals_set_expected(SIGCHLD, FALSE, sigchld_handler, NULL); } static void