home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / perl / 7493 < prev    next >
Encoding:
Internet Message Format  |  1992-12-17  |  1.3 KB

  1. Path: sparky!uunet!eiffel!eiffel.com
  2. From: ram@eiffel.com (Raphael Manfredi)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: system() vs exec()
  5. Message-ID: <160@eiffel.eiffel.com>
  6. Date: 17 Dec 92 18:36:47 GMT
  7. References: <mcook.724446650@fendahl.dev.cdx.mot.com> <1992Dec16.160845.17636@news.eng.convex.com> <2B30B274.616E@tct.com>
  8. Sender: ram@eiffel.com
  9. Organization: Interactive Software Engineering, Santa Barbara CA
  10. Lines: 29
  11.  
  12. Quoting chip@tct.com (Chip Salzenberg) from comp.lang.perl:
  13. >According to tchrist@convex.COM (Tom Christiansen):
  14. >>    sub system { fork ? wait : exec @_ }
  15. >
  16. >What if fork fails?  Try instead:
  17. >
  18. >    sub system {
  19. >        local($pid) = fork;
  20. >        return undef unless defined($pid);
  21. >        $pid ? wait : exec @_;
  22. >    }
  23.  
  24. What if exec fails? Try instead:
  25.  
  26.     sub system {
  27.         local($pid) = fork;
  28.         return undef unless defined($pid);
  29.         $pid ? wait : (exec(@_), exit 1);
  30.     }
  31.  
  32. >Note that, for non-BSD systems, you should check for EINTR; changes to
  33. >that effect are left as an exercise for the reader. :-)
  34.  
  35. Same comment holds.
  36. -- 
  37. Raphael Manfredi <ram@eiffel.com>
  38. Interactive Software Engineering Inc.
  39. 270 Storke Road, Suite #7                      / Tel +1 (805) 685-1006 \
  40. Goleta, California 93117, USA                  \ Fax +1 (805) 685-6869 /
  41.