Created
March 10, 2011 11:29
-
-
Save riywo/863968 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| my $pid = fork; | |
| if (!$pid){ | |
| local $SIG{TERM} = sub {exit 0}; | |
| for(1..5){ | |
| print "child process\n"; | |
| sleep 1; | |
| } | |
| exit; | |
| } else { | |
| sleep 3; | |
| die; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| my $pid = fork; | |
| if (!$pid){ | |
| local $SIG{TERM} = sub {exit 0}; | |
| for(1..5){ | |
| print "child process\n"; | |
| sleep 1; | |
| } | |
| exit; | |
| } else { | |
| local $SIG{__DIE__} = sub { | |
| kill 'TERM', $pid; | |
| }; | |
| sleep 3; | |
| die; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| my $pid = fork; | |
| if (!$pid){ | |
| local $SIG{TERM} = sub { | |
| sleep 2; | |
| print "child finish\n"; | |
| exit 0; | |
| }; | |
| for(1..5){ | |
| print "child process\n"; | |
| sleep 1; | |
| } | |
| exit; | |
| } else { | |
| eval{ | |
| sleep 3; | |
| die; | |
| }; | |
| if($@) { | |
| kill 'TERM', $pid; | |
| wait; | |
| die "$@"; | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
訂正:perl 5.12でも同じでした!失礼