home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!ftpbox!mothost!merlin.dev.cdx.mot.com!fendahl.dev.cdx.mot.com!mcook
- From: mcook@fendahl.dev.cdx.mot.com (Michael Cook)
- Subject: Re: system() vs exec()
- Message-ID: <mcook.724909902@fendahl.dev.cdx.mot.com>
- Sender: news@merlin.dev.cdx.mot.com (USENET News System)
- Nntp-Posting-Host: fendahl.dev.cdx.mot.com
- Organization: Motorola Codex, Canton, Massachusetts
- References: <mcook.724446650@fendahl.dev.cdx.mot.com> <1992Dec16.160845.17636@news.eng.convex.com>
- Date: Mon, 21 Dec 1992 03:51:42 GMT
- Lines: 27
-
- Tom Christiansen <tchrist@convex.COM> writes:
-
- >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, [...]
-
- Unfortunately, if the command has shell meta characters in it (and thus gets
- executed via "sh -c"), $signo will be zero ...at least, that's what happens on
- my system :-(
-
- Michael.
-