From: yoe Date: Fri, 4 Aug 2006 18:34:12 +0000 (+0000) Subject: r170: Use waitpid() rather than wait() to avoid it hanging while waiting for a X-Git-Url: http://git.alex.org.uk r170: Use waitpid() rather than wait() to avoid it hanging while waiting for a child if we receive a spurious SIGCHLD. --- diff --git a/nbd-server.c b/nbd-server.c index c21e3c6..e2463ae 100644 --- a/nbd-server.c +++ b/nbd-server.c @@ -536,12 +536,12 @@ GArray* parse_cfile(gchar* f, GError** e) { * is severely wrong) **/ void sigchld_handler(int s) { - int* status=NULL; + int status; int* i; pid_t pid; - while((pid=wait(status)) > 0) { - if(WIFEXITED(status)) { + while((pid=waitpid(-1, &status, WNOHANG)) > 0) { + if(WIFEXITED(&status)) { msg3(LOG_INFO, "Child exited with %d", WEXITSTATUS(status)); } i=g_hash_table_lookup(children, &pid);