in reply to Re: Re: Attempt to free unreferenced scalar...
in thread Attempt to free unreferenced scalar...

I notice that you didn't define &WNOHANG anywhere. To get WNOHANG, you have to say use POSIX ':sys_wait_h', but neither of the samples you posted do this.

  • Comment on Re: Attempt to free unreferenced scalar...

Replies are listed 'Best First'.
Re: Re: Attempt to free unreferenced scalar...
by Daniellek (Sexton) on Dec 19, 2000 at 13:46 UTC
    I have use POSIX; so i tought that :sys_wait_h is included there... I'll add this and check it right now.

    Update: I've added this line with :sys_wait_h and seems that nothing has changed.

    Here is process tree with the old (REAPER) version that has "unreferenced scalar" problem. Sometimes while many clients are connected there are more processes (I saw up to 8).

    30996 pts/0 S 0:00 \_ perl -w ./us2.pl 32396 pts/0 S 0:00 \_ perl -w ./us2.pl 32451 pts/0 R 0:00 | \_ perl -w ./us2.pl 32443 pts/0 S 0:00 \_ perl -w ./us2.pl 32450 pts/0 R 0:00 \_ perl -w ./us2.pl

    And here's the new version with :sys_wait_h It has 3 processes at most... and during heavy load it seems to work slower (bu this could be just illusion)

    831 pts/0 R 0:28 \_ perl -w ./us2.pl 1745 pts/0 S 0:00 \_ perl -w ./us2.pl 1776 pts/0 R 0:00 \_ perl -w ./us2.pl
    What else I can do to "help You to help me" ?

    UPDATE2:

    I think I've found it!

    The solution is compressing both methods in something like this:

    use POSIX ":sys_wait_h"; sub REAPER { my $child; while (($child = waitpid(-1,WNOHANG)) > 0) { $Kid_Status{$child} = $?; } $SIG{CHLD} = \&REAPER; # still loathe sysV } $SIG{CHLD} = \&REAPER; # do something that forks...
    (taken from perldoc.com)

    After some heavy testing (load average on my test computer grew to "48.30" :) I haven't seen any "unreferenced scalar" nor other errors.

    Does it look good for You? Or is there something ugly hidden in this method?

    (from some time i don't even trust my own linux box ;)

    -- Daniellek