problem in POSIX module with handling SIGCHLD

Discussion in 'Perl Misc' started by msoulier, Jul 15, 2005.

  1. msoulier

    msoulier Guest

    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
     
    msoulier, Jul 15, 2005
    #1
    1. Advertising

  2. msoulier <> 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.
     
    Ilmari Karonen, Jul 16, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. chuckles
    Replies:
    2
    Views:
    570
    chuckles
    Aug 18, 2005
  2. Dan Stromberg

    Re: Missing SIGCHLD

    Dan Stromberg, Feb 15, 2011, in forum: Python
    Replies:
    1
    Views:
    1,028
    Adam Skutt
    Feb 16, 2011
  3. Asfand Yar Qazi

    SIGCHLD handler not working correctly

    Asfand Yar Qazi, Dec 15, 2007, in forum: Ruby
    Replies:
    1
    Views:
    153
    Lionel Bouton
    Dec 15, 2007
  4. Moritz Karbach

    ignoring SIGCHLD

    Moritz Karbach, Jun 23, 2005, in forum: Perl Misc
    Replies:
    3
    Views:
    454
    Anno Siegel
    Jun 23, 2005
  5. Justin Fletcher

    sleep/fork/shell/SIGCHLD interaction problem

    Justin Fletcher, Nov 11, 2007, in forum: Perl Misc
    Replies:
    8
    Views:
    668
    Justin Fletcher
    Nov 15, 2007
Loading...

Share This Page