home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / programm / 4286 < prev    next >
Encoding:
Internet Message Format  |  1992-08-13  |  3.0 KB

  1. Path: sparky!uunet!olivea!apple!bionet!uwm.edu!cs.utexas.edu!ut-emx!ibmchs!auschs!awdprime.austin.ibm.com!ravikm
  2. From: ravikm@austin.ibm.com (Ravi K Mandava)
  3. Newsgroups: comp.unix.programmer
  4. Subject: Re: Children and waitpid()'s
  5. Message-ID: <1992Aug12.165656.8019@awdprime.austin.ibm.com>
  6. Date: 12 Aug 92 16:56:56 GMT
  7. References: <1992Aug12.034806.221488@zeus.calpoly.edu>
  8. Sender: news@awdprime.austin.ibm.com (USENET News)
  9. Reply-To: piobe!ravikm@ibmpa.awdpa.ibm.com
  10. Organization: IBM Austin
  11. Lines: 56
  12. Originator: ravikm@piobe.austin.ibm.com
  13.  
  14.  
  15. In article <1992Aug12.034806.221488@zeus.calpoly.edu>, kwang@zeus.calpoly.edu (Kevin Wang aka The Scarecrow) writes:
  16.  > exit value of the child.  My problem however is this:  the child exits
  17.  > before the parent can do a waitpid() on it, and I cannot get the exit value.
  18.  > 
  19.  > So I guess my quesions are thus:
  20.  > 1) under what circumstances does the child wait for the parent to ackowledge
  21.  > it's death (via waitpid())?
  22.  
  23.     Child process becomes a zombie (defunct) process, and remains like that
  24.     until either the parent does a wait()/waitpid() for it, or until the
  25.     parent exits.  That is, even if the child process exits before the
  26.     parent process calls waitpid(), the child process remains in defunct
  27.     state until the parent reads its exit status.  This is *only* true,
  28.     when the parent does not ignore the SIGCHLD (or SIGCLD) signal.
  29.     However, if the parent ignores the SIGCHLD signal (see man pages on
  30.     sigaction()), the child exits (and its process table entry is
  31.     immediately cleaned up) without passing its exit status to the parent.
  32.     That is, a wait() call by a parent would block until the child exits,
  33.     but does not fetch child's exit status.  Instead, errno is set to
  34.     ECHILD (no child processes).
  35.         
  36.  > 2) will a waitpid() on one process allow another to exit?
  37.  
  38.     No, unless the process id that is passed to it is not a positive
  39.     integer.  Man pages on waitpid() discuss all the possible scenarios
  40.     in this case.
  41.  
  42.  > 3) any better way to send messages to another program on another machine?
  43.  > (no filesystem access, only sockets)
  44.  
  45.     Sockets or TLI are the best bet, I guess.
  46.  
  47.  > 4) is it possible for signal(SIGCHLD...) to affect it?
  48.  
  49.     I presume you mean, if signal(SIGCHLD...) affects the behaviour of
  50.     a child being able to pass its exit status to the parent process.
  51.     As I discussed before, only if sigaction()/signal() is used to ignore
  52.     SIGCHLD, a child's exit status is not returned to its parent.
  53.  
  54.     However, one good suggestion is always to set up a signal handler
  55.     for SIGCHLD, in which a wait() can be performed to fetch the exit
  56.     status of a child and let it be purged from the system process table
  57.     immediately.
  58.  
  59.  > I am running on (ick) AIX 1.2.1
  60.  
  61.     The above comments should generally apply to any standard Unix/AIX
  62.     flavours.  But I could be wrong.  Would someone please correct me, if
  63.     so?
  64.  
  65. Hope this helps,
  66. -- 
  67. *******************************************************************************
  68. Ravi K Mandava        email:    piobe!ravikm@ibmpa.awdpa.ibm.com
  69. *******************************************************************************
  70.