Created
May 26, 2010 02:13
-
-
Save yaotti/413961 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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Linux::Pid qw/getpid getppid/; | |
my $pid = fork; | |
if( $pid ){ | |
warn "Parent: " . getpid(); | |
warn "Parent's parent: " . getppid(); | |
exit; | |
} else{ | |
#sleep 3; | |
warn "Child: " . getpid(); | |
warn "Parent pid: " . getppid(); | |
} | |
# Parent: 44361 at - line 8 | |
# Parent's parent: 17147 at - line 9 | |
# Child: 44362 at - line 13 | |
# Parent pid: 44361 at - line 14 | |
### sleep 3をコメントアウト(親が先に死ぬ) | |
# Parent: 44371 at - line 8 | |
# Parent's parent: 17147 at - line 9 | |
# Child: 44372 at - line 13 | |
# Parent pid: 1 at - line 14 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment