Path: utzoo!attcan!utgpu!watmath!att!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!ateng!chip From: chip@ateng.com (Chip Salzenberg) Newsgroups: comp.unix.questions Subject: Re: Converting wait3() to System V Message-ID: <2519795A.5880@ateng.com> Date: 22 Sep 89 00:14:15 GMT References: <10800032@bradley> Organization: A T Engineering, Tampa, FL Lines: 25 According to vijay@bradley.UUCP: > I hope you can give me some pointers. I am trying to port >an application from a 4.3 BSD UNIX to System V. There is a >wait3() call in the application that needs to be converted to >System V wait() or equivalent. And that's where I am stuck. Any help >would be appreciated. A non-blocking wait can be simulated (badly) with the already-suggested: int wstat, pid; alarm(1); pid = wait(&wstat); alarm(0); if (pid != -1) { /* We got a dead child */ } An alternative is to keep track of children as they die by strategic use of the SIGCLD signal. A SIGCLD signal catching routine will be called when a child process dies; it can then call wait() with the calm assurance that it won't block. Read the manual pages signal(2) and wait(2). A caveat: You'll pick up child processes created by library subroutines, too; this can mess up both them and you. Be careful with getpwd(), popen(), system() and any other forking library routines you may have.