home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / perl / 7487 < prev    next >
Encoding:
Text File  |  1992-12-17  |  1.0 KB  |  29 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!sybus.sybus.com!myrddin!tct!chip
  3. From: chip@tct.com (Chip Salzenberg)
  4. Subject: Re: system() vs exec()
  5. Message-ID: <2B30B274.616E@tct.com>
  6. Date: Thu, 17 Dec 1992 17:01:40 GMT
  7. References: <mcook.724446650@fendahl.dev.cdx.mot.com> <1992Dec16.160845.17636@news.eng.convex.com>
  8. Organization: TC Telemanagement, Clearwater, FL
  9. Lines: 18
  10.  
  11. According to tchrist@convex.COM (Tom Christiansen):
  12. >    sub system { fork ? wait : exec @_ }
  13.  
  14. What if fork fails?  Try instead:
  15.  
  16.     sub system {
  17.         local($pid) = fork;
  18.         return undef unless defined($pid);
  19.         $pid ? wait : exec @_;
  20.     }
  21.  
  22. Note that, for non-BSD systems, you should check for EINTR; changes to
  23. that effect are left as an exercise for the reader. :-)
  24. -- 
  25. Chip Salzenberg at Teltronics/TCT  <chip@tct.com>, <73717.366@compuserve.com>
  26.   "you make me want to break the laws of time and space / you make me
  27.    want to eat pork / you make me want to staple bagles to my face /
  28.    and remove them with a pitchfork" -- Weird Al Yankovic, "You Make Me"
  29.