Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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.


In reply to Re^3: Multiple system commands in parallel by Tanktalus
in thread Multiple system commands in parallel by g_speran

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-03-29 14:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found