From 4f93d4e0b9252227d1b204b4e6fbc85e96df6df0 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 17 Sep 1997 21:08:57 +0000 Subject: Better portability, I hope... svn path=/trunk/; revision=1361 --- daemon.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/daemon.c b/daemon.c index 7ca19ff8..f71d0343 100644 --- a/daemon.c +++ b/daemon.c @@ -54,28 +54,25 @@ RETSIGTYPE sigchld_handler (int sig) /* process SIGCHLD to obtain the exit code of the terminating process */ { - pid_t pid; + pid_t pid; +#if defined(HAVE_WAITPID) /* the POSIX way */ + int status; + + while ((pid = waitpid(-1, &status, WNOHANG)) > 0) + continue; /* swallow 'em up. */ +#elif defined(HAVE_WAIT3) /* the BSD way */ #if defined(HAVE_UNION_WAIT) && !defined(__FreeBSD__) - union wait status; + union wait status; #else - int status; + int status; #endif -#if defined(HAVE_WAIT3) -#ifdef oldhpux /* HP-UX fixed this sometime between 9.01 and 10.20 */ - while ((pid = wait3(&status, WNOHANG, (int *) 0)) > 0) -#else - while ((pid = wait3(&status, WNOHANG, (struct rusage *) 0)) > 0) -#endif - ; /* swallow 'em up. */ -#elif defined(HAVE_WAITPID) - while ((pid = waitpid(-1, &status, WNOHANG)) > 0) - ; /* swallow 'em up. */ + while ((pid = wait3(&status, WNOHANG, 0)) > 0) + continue; /* swallow 'em up. */ #else /* Zooks! Nothing to do but wait(), and hope we don't block... */ - wait(&status); + wait(&status); #endif - } int -- cgit v1.2.3