hbo has asked for the wisdom of the Perl Monks concerning the following question:
This program outputs the following:#!/usr/bin/perl use POSIX qw(pause); use strict; my $ppid=$$; $SIG{HUP}=sub {return}; my $pid=fork; if ($pid){ pause; print "parent woke up\n"; waitpid $pid,0; print "parent reaped child\n"; } else { die "fork error $!" if (!defined $pid); sleep 2; # what can I say, it works. print "child is about to signal parent (at $ppid)\n"; # `kill -1 $ppid`; my $cnt=kill,1,$ppid; print "child signaled $cnt process(es)\n"; print "child about to exit\n"; exit; }
A 'kill -1 $ppid' from the shell gets the program unstuck. If I comment out the internal kill function and subsequent print statement, and uncomment the back-tick kill, it works as I'd like:hbo@owen|1337> perl test child is about to signal parent (at 24421) child signaled 0 process(es) child about to exit
I've never gotten Perl's built-in kill to work for me. Any ideas?hbo@owen|1338> perl test child is about to signal parent (at 24428) parent woke up child about to exit parent reaped child
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: kill no workee
by hbo (Monk) on Jun 10, 2003 at 02:21 UTC | |
by daeve (Deacon) on Jun 10, 2003 at 05:04 UTC |