# HG changeset patch # User Bruno Haible # Date 1213098934 -7200 # Node ID b67d0f4f15135d14c41b850c4f2107a8d6197bab # Parent 0553e4d56bcc0d8fafadc5bbd5fbe41dbb3abfe4 Try to fix waitid() based code. diff -r 0553e4d56bcc -r b67d0f4f1513 ChangeLog --- a/ChangeLog Tue Jun 10 12:13:43 2008 +0200 +++ b/ChangeLog Tue Jun 10 13:55:34 2008 +0200 @@ -1,3 +1,7 @@ +2008-06-10 Bruno Haible + + * lib/wait-process.c (wait_subprocess): Try to fix waitid() based code. + 2008-06-10 Bruno Haible * tests/test-memmem.c (main): Reset SIGALRM to default handling before diff -r 0553e4d56bcc -r b67d0f4f1513 lib/wait-process.c --- a/lib/wait-process.c Tue Jun 10 12:13:43 2008 +0200 +++ b/lib/wait-process.c Tue Jun 10 13:55:34 2008 +0200 @@ -253,9 +253,9 @@ bool slave_process, bool exit_on_error) { #if HAVE_WAITID && defined WNOWAIT && 0 - /* Commented out because waitid() with WNOWAIT doesn't work: On Solaris 7 - and OSF/1 4.0, it returns -1 and sets errno = ECHILD, and on HP-UX 10.20 - it just hangs. */ + /* Commented out because waitid() without WEXITED and with WNOWAIT doesn't + work: On Solaris 7 and OSF/1 4.0, it returns -1 and sets errno = ECHILD, + and on HP-UX 10.20 it just hangs. */ /* Use of waitid() with WNOWAIT avoids a race condition: If slave_process is true, and this process sleeps a very long time between the return from waitpid() and the execution of unregister_slave_subprocess(), and @@ -265,7 +265,8 @@ siginfo_t info; for (;;) { - if (waitid (P_PID, child, &info, slave_process ? WNOWAIT : 0) < 0) + if (waitid (P_PID, child, &info, WEXITED | (slave_process ? WNOWAIT : 0)) + < 0) { # ifdef EINTR if (errno == EINTR) @@ -297,7 +298,7 @@ /* Now remove the zombie from the process list. */ for (;;) { - if (waitid (P_PID, child, &info, 0) < 0) + if (waitid (P_PID, child, &info, WEXITED) < 0) { # ifdef EINTR if (errno == EINTR)