Posted on 2007-03-02 21:23:44-08 by sbperl
Why does net::scp::expect handle CHLD signal?

I am wondering why the code in Net::SCP::Expect handles the CHLD signal (line 16: $SIG{CHLD} = < code ref>)? The "Programming Perl" book says "If you start another process using in Perl using anything except fork, Perl takes care of reaping your zombied children...". Net::SCP::Expect does not use fork. However, the Expect module that does the underlying forking does use fork, but this code appears to be handling child process reaping using waitpid(...).

If another Perl package "use"'s Net::SCP::Expect, the assignment to $SIG{CHLD} in Net::SCP::Expect will be executed after Perl executes the 'use' statement. This has side-effects in the containing Perl package (assuming the containing package does not assign to SIG{CHLD}) - using 'open' or a backquote expression will result in $? always evaluating to -1 (to indicate that no child process was found).

Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.