#!/usr/local/bin/perl -w
use strict;
$SIG{__DIE__} = sub {warn "uurk\n"; kill(9, -$$)};
if (my $pid=fork) {
my $i=0;
do {
sleep 1;
print "Parent thread ($$) - not dead yet...\n";
$i++;
} until $i == 3;
die;
} elsif (defined $pid) {
do {
sleep 1;
print "Child thread ($$) - not dead yet...\n";
} until 1 == 0;
}
####
bio-man@saturn [dbupdate] ./ugly_forker
Parent thread (17387) - not dead yet...
Child thread (17388) - not dead yet...
Parent thread (17387) - not dead yet...
Child thread (17388) - not dead yet...
Parent thread (17387) - not dead yet...
Child thread (17388) - not dead yet...
uurk
Killed
bio-man@saturn [dbupdate]
####
#!/usr/local/bin/perl -w
use strict;
$SIG{__DIE__} = sub {warn "uurk\n"; kill(9, -$$)};
if (my $pid=fork) {
do {
sleep 1;
print "Parent thread ($$) - not dead yet...\n";
} until 1 == 0;
} elsif (defined $pid) {
my $i=0;
do {
sleep 1;
print "Child thread ($$) - not dead yet...\n";
$i++;
} until $i == 3;
die;
}
####
bio-man@saturn [dbupdate] ./ugly_forker
Parent thread (19689) - not dead yet...
Child thread (19690) - not dead yet...
Parent thread (19689) - not dead yet...
Child thread (19690) - not dead yet...
Parent thread (19689) - not dead yet...
Child thread (19690) - not dead yet...
uurk
Died at ./ugly_forker line 91.
Parent thread (19689) - not dead yet...
Parent thread (19689) - not dead yet...
^C
bio-man@saturn [dbupdate]