Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^3: Multiple system commands in parallel

by Tanktalus (Canon)
on May 09, 2016 at 21:22 UTC ( #1162574=note: print w/replies, xml ) Need Help??

in reply to Re^2: Multiple system commands in parallel
in thread Multiple system commands in parallel

I'm not 100% sure about what's required on Windows. What may work is to set $SIG{INT} to "IGNORE" before spawning the children. Note that when you do so, your process won't be killed by ctrl-C, either - you'll just keep going.

Another option may be to fork/exec yourself instead of using system, and in the "child" process, do the above - that way the parent process will still be killable partway through while the children will continue to live on their own, e.g.:

for ($x=0; $x < scalar(@files); $x++ ) { $file=@files[$x]; chomp $file; $cmd="clone -F $file "; print "Launching Command is: $cmd\n"; my $pid = fork; if ($pid) { # parent } elsif (defined $pid) { $SIG{INT} = 'IGNORE'; exec($cmd); } else { die "fork failed."; } }
This variation you can still hit Ctrl-C to kill the parent, but the children will inherit the ignore status on the signal handler and keep going. (This can also be done in the on_prepare callback in AnyEvent::Util::run_cmd.)

Finally, if you have control over the clone command, you can have that program ignore the INT signal.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1162574]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2021-09-18 18:15 GMT
Find Nodes?
    Voting Booth?

    No recent polls found