Closed p5pRT closed 21 years ago
The kill function seems to think it killed a pid even when it hasn't. I've looked up the usage of the kill command in both O'Reily's Programming Perl and the perlipc man page. There's even a chunk of code in that man page that says pretty much the same thing as this example:
#!/usr/bin/perl
if(!defined($kid_pid = fork())) { die "Unforkable? Well THAT ruins story time! $!\n"; } elsif($kid_pid == 0) { print "\"Yay! I'm the child!\" exclaims child $kid_pid.\n"; print "The child goes to sleep\, oblivious of its short future.\n\n"; sleep(500); exit(0); } else { sleep(1); print "\"Buwahahaha\, child! I will brutally murder you while you "; print "peacefully sleep!\" cackles the homicidal parent!\n"; sleep(3); print "The parent sneaks upstairs!\n"; sleep(1); $temp = kill('TERM'\, $kid_pid); printf "The parent attacks!!!! He kills %d child%s!!!\n"\, $temp\, ($temp == 1) ? "" : "ren"; sleep(1); $temp2 = kill(0\, $kid_pid); printf "He decides that isn't enough\, and dices %d more poor child%s to pieces!!!\n"\, $temp2\, ($temp2 == 1) ? "" : "ren"; }
When I run this program\, it says that it's killed 1 child in each of its messages. I made it sleep in all those places on the off chance that the problem was that things were executing too quickly & tripping all over each other.
Am I doing something stupidly wrong?
Thanks\, David Hoover
Migrated from rt.perl.org#999 (status was 'resolved')
Searchable as RT999$