Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

WNOHANG seem to help

by petr999 (Acolyte)
on Mar 02, 2011 at 22:50 UTC ( [id://891122]=note: print w/replies, xml ) Need Help??


in reply to Check if forked process is dead

It works now. Thanks all.
$ perl -Mstrict -MPOSIX -wE 'my $pid = fork; if( $pid ){ kill TERM => +$pid; foreach( 1..5 ){ sleep 1; waitpid $pid => WNOHANG; my $rv = kil +l 0 => $pid; say $rv; exit unless $rv; } kill KILL => $pid; waitpid $ +pid => 0; } else { BEGIN{ $SIG{TERM}=sub{ say "TERM!"; }; } sleep 3; + exit; }' TERM! 1 1 0 $ perl -Mstrict -MPOSIX -wE 'my $pid = fork; if( $pid ){ kill TERM => +$pid; foreach( 1..3 ){ sleep 1; waitpid $pid => WNOHANG; my $rv = kil +l 0 => $pid; say $rv; exit unless $rv; } kill KILL => $pid; waitpid $ +pid => 0; } else { BEGIN{ $SIG{TERM}=sub{ say "TERM!"; }; } sleep 5; + exit; }' TERM! 1 1 1 $

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-06-24 17:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.