From ca8e8303a1a02a5795e484f50544a4c21a1676c0 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Fri, 21 Mar 2008 13:42:02 +0100 Subject: [PATCH] Fix wait_pro_process(). The old code was racy. --- dss.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dss.c b/dss.c index d77fef2..8b8e4bb 100644 --- a/dss.c +++ b/dss.c @@ -383,10 +383,14 @@ int wait_for_process(pid_t pid, int *status) DSS_DEBUG_LOG("Waiting for process %d to terminate\n", (int)pid); for (;;) { - pause(); - ret = next_signal(); + fd_set rfds; + + FD_ZERO(&rfds); + FD_SET(signal_pipe, &rfds); + ret = dss_select(signal_pipe + 1, &rfds, NULL, NULL); if (ret < 0) break; + ret = next_signal(); if (!ret) continue; if (ret == SIGCHLD) { @@ -1096,6 +1100,7 @@ int main(int argc, char **argv) cmdline_parser_ext(argc, argv, &conf, ¶ms); /* aborts on errors */ parse_config_file(0); + if (conf.daemon_given) daemon_init(); setup_signal_handling(); -- 2.39.5