home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / programm / 5845 < prev    next >
Encoding:
Text File  |  1993-01-06  |  1.9 KB  |  47 lines

  1. Newsgroups: comp.unix.programmer
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!uwm.edu!linac!att!mcdchg!mcdphx!mre
  3. From: mre@phx.mcd.mot.com (Mark Enstone)
  4. Subject: Re: Which Child?
  5. Message-ID: <1993Jan6.223823.15038@phx.mcd.mot.com>
  6. Keywords: child fork
  7. Sender: news@phx.mcd.mot.com
  8. Nntp-Posting-Host: tacheon.phx.mcd.mot.com
  9. Organization: Motorola Computer Group, Tempe, Az.
  10. References: <C0Fyxx.ABn@cerc.wvu.wvnet.edu>
  11. Date: Wed, 6 Jan 1993 22:38:23 GMT
  12. Lines: 33
  13.  
  14. In article <C0Fyxx.ABn@cerc.wvu.wvnet.edu> abmg@cerc.wvu.wvnet.edu (Aliasghar Babadi) writes:
  15. >Hi,
  16. >    I have a program which forks several child processes. If one
  17. >child is terminated. Is there a way to findout which child has been  
  18. >terminated? Thanks.
  19.  
  20. wait(2)
  21.  
  22. "and if a child process stopped or terminated prior to the call on wait,
  23. return is immediate."
  24.  
  25. "If wait returns due to a stopped or terminated child process, the process
  26. ID of the child is returned to the calling process. Otherwise, a value of
  27. -1 is returned and errno is set to indicate the error."
  28.  
  29. Therefore, what you're after is the return value from wait (&stat_loc)
  30. system call.
  31.  
  32. All sorts of other good stuff are returned in stat_loc. May I perhaps suggest
  33. RTM on the wait(2) system call.
  34.  
  35. You're welcome,
  36.  
  37. - mark
  38. A.k.a.                              ,,,
  39.                                    (o o)
  40. +------------------------------oOO--(_)--OOo-----------------------------------+
  41. | Mark Enstone                       |                                         |
  42. | Motorola Inc.,                     | uucp : mre@phx.mcd.mot.com              |
  43. | Fault Tolerant Computing           | phone: (602) 438 3284                   |
  44. | 2900 South Diablo Way, DW220       | fax  : (602) 438 3836                   |
  45. | Tempe, Arizona 85282, USA          | icbm : mid-southwestern US desert       |
  46. +------------------------------------+-----------------------------------------+
  47.