home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / programm / 5228 < prev    next >
Encoding:
Internet Message Format  |  1992-11-09  |  1.5 KB

  1. Path: sparky!uunet!ferkel.ucsb.edu!taco!rock!stanford.edu!ames!sun-barr!rutgers!njitgw.njit.edu!hertz.njit.edu!jxv3790
  2. From: jxv3790@hertz.njit.edu (Jake Vogelaar)
  3. Newsgroups: comp.unix.programmer
  4. Subject: Need help with signal handling !
  5. Keywords: SIGCLD & wait()
  6. Message-ID: <1992Nov10.052631.26541@njitgw.njit.edu>
  7. Date: 10 Nov 92 05:26:31 GMT
  8. Sender: news@njit.edu
  9. Organization: New Jersey Institute of Technology, Newark, N.J.
  10. Lines: 24
  11. Nntp-Posting-Host: hertz.njit.edu
  12.  
  13. I'm writing a simple shell that needs to output info on the event of the
  14. death of any of its children.  I have been trying to implement this by
  15. writing a function that caught SIGCLD did a wait3 and than a wait for 
  16. the death of the child.  Since this is system V (or Ultrix) I reset the
  17. signal handler in the function every time.
  18.  
  19. In the main program I have a loop like this:
  20.                   if ((frk=fork())==0) 
  21.                     /* child execlp */
  22.                   else if frk==-1 error();
  23.                   else if (!ampersand) wait(&status);
  24. no problems with this if the command line has no '&', but if it does than
  25. both the child and the parent shell exit.  (gdb reports a SEGV error)
  26.  
  27. Anybody know what I'm doing wrong, or how to implement this in a better way?
  28.  
  29. Thanks,
  30.  
  31. -jake
  32. -- 
  33. /////////////////////////////////////////////////////////////////////////
  34. Jake Vogelaar, jxv3790@hertz.njit.edu
  35. Computer Vision R&D, Warner-Lambert Manufacturing Development Laboratory
  36. New Jersey Institute of Technology
  37.