Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

kill no workee

by hbo (Monk)
on Jun 10, 2003 at 02:12 UTC ( [id://264523]=perlquestion: print w/replies, xml ) Need Help??

hbo has asked for the wisdom of the Perl Monks concerning the following question:

On Linux, with Perl 5.8.0 (but on many another combination of OS and Perl version) the following code doesn't do what I expect:
#!/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; }
This program outputs the following:
hbo@owen|1337> perl test child is about to signal parent (at 24421) child signaled 0 process(es) child about to 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|1338> perl test child is about to signal parent (at 24428) parent woke up child about to exit parent reaped child
I've never gotten Perl's built-in kill to work for me. Any ideas?

Replies are listed 'Best First'.
Re: kill no workee
by hbo (Monk) on Jun 10, 2003 at 02:21 UTC
    So, why is it I can't see the extra comma in the kill statement until after I post the question? 8(

    Sorry for wasting your time.
      ++ for coming back on and posting, both that you had found the problem, and for telling us what it was.

      I wish more people would do that. A lot of folks come back and say "thanks for all the great help" but never come back and say "Well thus and so was what I had and with your help this is what I ended up with". Follow through is nice. ;-)

      Just my $0.02
      Daeve

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://264523]
Approved by rob_au
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-26 05:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found