Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > problem in POSIX module with handling SIGCHLD

Reply
Thread Tools

problem in POSIX module with handling SIGCHLD

 
 
msoulier
Guest
Posts: n/a
 
      07-15-2005
Reading my faithful Perl Cookbook on reaping children (wow that sounds
bad), I found this recipe.

use POSIX ":sys_wait_h";

$SIG{CHLD} = \&REAPER;
sub REAPER {
my $stiff;
while (($stiff = waitpid(-1, &WNOHANG)) > 0) {
# do something with $stiff if you want
}
$SIG{CHLD} = \&REAPER; # install *after* calling
waitpid
}

Unfortunately, when I use this, while it works, I get this warning from
POSIX:

Argument "CHLD" isn't numeric in subroutine entry at
/usr/lib/perl5/5.6.1/i386-linux/POSIX.pm line 38.

Seems that there is no symbol 'CHLD' in that module, and it's trying to
AUTOLOAD a subroutine.

Anyone else seen this? I'm using

# perl -v

This is perl, v5.6.1 built for i386-linux

Thanks,
Mike

 
Reply With Quote
 
 
 
 
Ilmari Karonen
Guest
Posts: n/a
 
      07-15-2005
msoulier <(E-Mail Removed)> kirjoitti 15.07.2005:
> Reading my faithful Perl Cookbook on reaping children (wow that sounds
> bad), I found this recipe.
>
> use POSIX ":sys_wait_h";
>
> $SIG{CHLD} = \&REAPER;
> sub REAPER {
> my $stiff;
> while (($stiff = waitpid(-1, &WNOHANG)) > 0) {
> # do something with $stiff if you want
> }
> $SIG{CHLD} = \&REAPER; # install *after* calling waitpid
> }
>
> Unfortunately, when I use this, while it works, I get this warning from
> POSIX:
>
> Argument "CHLD" isn't numeric in subroutine entry at
> /usr/lib/perl5/5.6.1/i386-linux/POSIX.pm line 38.


Strange. I get no such warning. Do you actually get that warning
when you run only the code you posted, or does it only appear when the
code is used as part of a larger program?

> Seems that there is no symbol 'CHLD' in that module, and it's trying to
> AUTOLOAD a subroutine.


In the code you posted, 'CHLD' is only used as a hash key. The only
symbol exported by POSIX.pm and used in that code is WNOHANG.

> This is perl, v5.6.1 built for i386-linux


This is perl, v5.8.4 built for i386-linux-thread-multi

--
Ilmari Karonen
To reply by e-mail, please replace ".invalid" with ".net" in address.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Missing SIGCHLD Dan Stromberg Python 1 02-16-2011 05:22 AM
SIGCHLD handler not working correctly Asfand Yar Qazi Ruby 1 12-15-2007 01:05 PM
sleep/fork/shell/SIGCHLD interaction problem Justin Fletcher Perl Misc 8 11-15-2007 08:52 AM
Does pthread emit a sigchld signal on successful exit? chuckles C Programming 2 08-18-2005 09:29 PM
ignoring SIGCHLD Moritz Karbach Perl Misc 3 06-23-2005 12:41 PM



Advertisments