home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!cs.utexas.edu!hermes.chpc.utexas.edu!news.utdallas.edu!convex!tchrist
- From: Tom Christiansen <tchrist@convex.COM>
- Subject: Re: system() vs exec()
- Originator: tchrist@pixel.convex.com
- Sender: usenet@news.eng.convex.com (news access account)
- Message-ID: <1992Dec16.160845.17636@news.eng.convex.com>
- Date: Wed, 16 Dec 1992 16:08:45 GMT
- Reply-To: tchrist@convex.COM (Tom Christiansen)
- References: <mcook.724446650@fendahl.dev.cdx.mot.com>
- Nntp-Posting-Host: pixel.convex.com
- Organization: Convex Computer Corporation, Colorado Springs, CO
- X-Disclaimer: This message was written by a user at CONVEX Computer
- Corp. The opinions expressed are those of the user and
- not necessarily those of CONVEX.
- Lines: 28
-
- From the keyboard of mcook@fendahl.dev.cdx.mot.com (Michael Cook):
- :This means that a Perl script that use system() can be difficult to interrupt.
- : foreach (@files)
- : {
- : system("cp $_ $dest/$_");
- : $exit = $? if $?;
- : }
- : exit($exit);
- :
- :If you try to ^C this script, it will simply start a new iteration of the
- :foreach loop (most likely).
- :
- :If you write the script using fork, exec and waitpid, when you hit ^C it does
- :what you'd expect: it dies.
- :
- :At best, this is a bug in the manpage. At worst, it is a bug in perl.
-
- Well, it's really just behaving like system(3) out of the C library.
- You can always check ($signo = $? & 127) on many systems, or write
-
- sub system { fork ? wait : exec @_ }
-
- --tom
- --
- Tom Christiansen tchrist@convex.com convex!tchrist
- There are probably better ways to do that, but it would make the parser
- more complex. I do, occasionally, struggle feebly against complexity... :-)
- --Larry Wall in <7886@jpl-devvax.JPL.NASA.GOV>
-