home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!eiffel!eiffel.com
- From: ram@eiffel.com (Raphael Manfredi)
- Newsgroups: comp.lang.perl
- Subject: Re: system() vs exec()
- Message-ID: <160@eiffel.eiffel.com>
- Date: 17 Dec 92 18:36:47 GMT
- References: <mcook.724446650@fendahl.dev.cdx.mot.com> <1992Dec16.160845.17636@news.eng.convex.com> <2B30B274.616E@tct.com>
- Sender: ram@eiffel.com
- Organization: Interactive Software Engineering, Santa Barbara CA
- Lines: 29
-
- Quoting chip@tct.com (Chip Salzenberg) from comp.lang.perl:
- >According to tchrist@convex.COM (Tom Christiansen):
- >> sub system { fork ? wait : exec @_ }
- >
- >What if fork fails? Try instead:
- >
- > sub system {
- > local($pid) = fork;
- > return undef unless defined($pid);
- > $pid ? wait : exec @_;
- > }
-
- What if exec fails? Try instead:
-
- sub system {
- local($pid) = fork;
- return undef unless defined($pid);
- $pid ? wait : (exec(@_), exit 1);
- }
-
- >Note that, for non-BSD systems, you should check for EINTR; changes to
- >that effect are left as an exercise for the reader. :-)
-
- Same comment holds.
- --
- Raphael Manfredi <ram@eiffel.com>
- Interactive Software Engineering Inc.
- 270 Storke Road, Suite #7 / Tel +1 (805) 685-1006 \
- Goleta, California 93117, USA \ Fax +1 (805) 685-6869 /
-