Path: utzoo!mnetor!uunet!husc6!rutgers!labrea!jade!ucbvax!ZORAC.ARPA!tim From: tim@ZORAC.ARPA (Tim Pointing) Newsgroups: comp.sys.sgi Subject: wait3 Message-ID: <8712081347.AA20022@zorac.ARPA> Date: 8 Dec 87 13:47:04 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The ARPA Internet Lines: 66 Often, the only reason why wait3() is used instead of wait() is so that a wait can be done without delaying if there is no child process have status to report (where wait() would just sit around until one did have status to report.) The way that I have kludged around this deficiency in the past is with my own hack which sort-of simulates wait3(). Good Luck! Tim Caveats: I am typing this in off the top of my head - it may not work as typed (additional #include's may be required); it will not work when the option "WUNTRACED" is used; care must be taken if alarm's are already being used in the program. No guarantees! The fake goes something like (this at least compiles)... -------------cut-here-----------------------------------cut-here------------ #include#include #include #include #include #include typedef int (*PFI)(); /* make declarations easier to read */ wait3(status, options, rusage) union wait *status; int options; struct resource *rusage; /* not altered so declaration doesn't matter */ { extern int wait3_timeout(); PFI old_alarm, signal(); int pid; extern int errno; int err_code; unsigned time_left; /* fake the WNOHANG option by using time-out's */ if (options & WNOHANG) { old_alarm = signal(SIGALRM, wait3_timeout); time_left = alarm(1); } errno = 0; pid = wait(status); err_code = errno; if (options & WNOHANG) { (void) signal(SIGALRM, old_alarm); alarm(time_left); } /* pid == -1 means either no process to wait for or alarm */ /* interupted the wait() system call. */ if (pid == -1 && err_code == EINTR) return(0); return(pid); } static wait3_timeout() {}