problem in POSIX module with handling SIGCHLD

M

msoulier

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
 
I

Ilmari Karonen

msoulier said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top