home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!apple!bionet!uwm.edu!cs.utexas.edu!ut-emx!ibmchs!auschs!awdprime.austin.ibm.com!ravikm
- From: ravikm@austin.ibm.com (Ravi K Mandava)
- Newsgroups: comp.unix.programmer
- Subject: Re: Children and waitpid()'s
- Message-ID: <1992Aug12.165656.8019@awdprime.austin.ibm.com>
- Date: 12 Aug 92 16:56:56 GMT
- References: <1992Aug12.034806.221488@zeus.calpoly.edu>
- Sender: news@awdprime.austin.ibm.com (USENET News)
- Reply-To: piobe!ravikm@ibmpa.awdpa.ibm.com
- Organization: IBM Austin
- Lines: 56
- Originator: ravikm@piobe.austin.ibm.com
-
-
- In article <1992Aug12.034806.221488@zeus.calpoly.edu>, kwang@zeus.calpoly.edu (Kevin Wang aka The Scarecrow) writes:
- > exit value of the child. My problem however is this: the child exits
- > before the parent can do a waitpid() on it, and I cannot get the exit value.
- >
- > So I guess my quesions are thus:
- > 1) under what circumstances does the child wait for the parent to ackowledge
- > it's death (via waitpid())?
-
- Child process becomes a zombie (defunct) process, and remains like that
- until either the parent does a wait()/waitpid() for it, or until the
- parent exits. That is, even if the child process exits before the
- parent process calls waitpid(), the child process remains in defunct
- state until the parent reads its exit status. This is *only* true,
- when the parent does not ignore the SIGCHLD (or SIGCLD) signal.
- However, if the parent ignores the SIGCHLD signal (see man pages on
- sigaction()), the child exits (and its process table entry is
- immediately cleaned up) without passing its exit status to the parent.
- That is, a wait() call by a parent would block until the child exits,
- but does not fetch child's exit status. Instead, errno is set to
- ECHILD (no child processes).
-
- > 2) will a waitpid() on one process allow another to exit?
-
- No, unless the process id that is passed to it is not a positive
- integer. Man pages on waitpid() discuss all the possible scenarios
- in this case.
-
- > 3) any better way to send messages to another program on another machine?
- > (no filesystem access, only sockets)
-
- Sockets or TLI are the best bet, I guess.
-
- > 4) is it possible for signal(SIGCHLD...) to affect it?
-
- I presume you mean, if signal(SIGCHLD...) affects the behaviour of
- a child being able to pass its exit status to the parent process.
- As I discussed before, only if sigaction()/signal() is used to ignore
- SIGCHLD, a child's exit status is not returned to its parent.
-
- However, one good suggestion is always to set up a signal handler
- for SIGCHLD, in which a wait() can be performed to fetch the exit
- status of a child and let it be purged from the system process table
- immediately.
-
- > I am running on (ick) AIX 1.2.1
-
- The above comments should generally apply to any standard Unix/AIX
- flavours. But I could be wrong. Would someone please correct me, if
- so?
-
- Hope this helps,
- --
- *******************************************************************************
- Ravi K Mandava email: piobe!ravikm@ibmpa.awdpa.ibm.com
- *******************************************************************************
-