>>>>> "GL" == Greg London <[EMAIL PROTECTED]> writes:

  GL> I've got a script that's doing a bunch of system commands,
  GL> some of these system commands take a long time,
  GL> such as a recursive copy on a large directory structure.

  GL> It seems that if the user presses control-C during the
  GL> copy command, the command quits, but then the perl script
  GL> seems to continue on from that point.

the problem is that the system's command is catching the signal and
dying. it is the active process attached to the terminal and so it gets
the signal. the perl process is waiting on it.

  GL> I'm not doing an eval around the system() call.

that isn't needed.

  GL> After the system call, how do I test for a control-c
  GL> as the cause for the command ending?

look at $@ and check for why the process died. you can extract a signal
number from it (shift 8 bits and mask IIRC, rtfm for details. i think
perlvar covers it).

  GL> Oh, and I can't simply say

  GL> system('cp -r longtree dest')==0 or die $@;

  GL> because some system commands will fail because the
  GL> directory doesn't exist or something, and in those
  GL> cases, I want the script to keep going.

just check for SIGINT and handle that.

uri

-- 
Uri Guttman  ------  [EMAIL PROTECTED]  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to