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

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!ftpbox!mothost!merlin.dev.cdx.mot.com!fendahl.dev.cdx.mot.com!mcook
  3. From: mcook@fendahl.dev.cdx.mot.com (Michael Cook)
  4. Subject: Re: system() vs exec()
  5. Message-ID: <mcook.724909902@fendahl.dev.cdx.mot.com>
  6. Sender: news@merlin.dev.cdx.mot.com (USENET News System)
  7. Nntp-Posting-Host: fendahl.dev.cdx.mot.com
  8. Organization: Motorola Codex, Canton, Massachusetts
  9. References: <mcook.724446650@fendahl.dev.cdx.mot.com> <1992Dec16.160845.17636@news.eng.convex.com>
  10. Date: Mon, 21 Dec 1992 03:51:42 GMT
  11. Lines: 27
  12.  
  13. Tom Christiansen <tchrist@convex.COM> writes:
  14.  
  15. >From the keyboard of mcook@fendahl.dev.cdx.mot.com (Michael Cook):
  16. >:This means that a Perl script that use system() can be difficult to interrupt.
  17. >:  foreach (@files)
  18. >:  {
  19. >:    system("cp $_ $dest/$_");
  20. >:    $exit = $? if $?;
  21. >:  }
  22. >:  exit($exit);
  23. >:
  24. >:If you try to ^C this script, it will simply start a new iteration of the
  25. >:foreach loop (most likely).
  26. >:
  27. >:If you write the script using fork, exec and waitpid, when you hit ^C it does
  28. >:what you'd expect: it dies.
  29. >:
  30. >:At best, this is a bug in the manpage.  At worst, it is a bug in perl.
  31.  
  32. >Well, it's really just behaving like system(3) out of the C library.
  33. >You can always check ($signo = $? & 127) on many systems, [...]
  34.  
  35. Unfortunately, if the command has shell meta characters in it (and thus gets
  36. executed via "sh -c"), $signo will be zero ...at least, that's what happens on
  37. my system :-(
  38.  
  39. Michael.
  40.