develooper Front page | perl.perl5.porters | Postings from November 1999

User SIG{CHLD} handler confusing perl internals

Tom Christiansen
November 12, 1999 06:18
User SIG{CHLD} handler confusing perl internals
Message ID:
The following question comes up reasonably often.  Is the correct fix
just to document it somewhere, like perlvar and perlipc and perhaps
perlfunc all over, or is there something that can be done in the core
to work-around the matter?  Just this week someone asked me why close()
on a pipe returned failure on one system but not on another.  The answer
was that the first system was Sloaris and he had had his own $SIG{CHLD}
handler that was reaping the kid out from under perl.


:From: "Matthew O. Persico" <>
:Newsgroups: comp.lang.perl.moderated
:Subject: Re: Fork()ed up and don't know why...
:Date: Thu, 11 Nov 1999 20:21:31 -0500
:Message-ID: <>
:References: <>
:"Brandon S. Allbery KF8NH" wrote:
:> In article <>, you said:
:> +-----
:> | I used the return value of system(), the value of close(FOO) after calling
:> | open(FOO,"theCommand |") and the value of $? after using backticks. No
:> +--->8
:> All of those return the actual status value from wait(), which is a bitmap.
:> If !=0 && >=256, $retval>>8 is the exit status; if <256, $retval&255 is the
:> signal that killed the process and $retval&128 is !=0 if it dumped core.
:> "man wait" for more information.  also "perldoc POSIX" and search for "wait"
:> for a more C-like way of handling exit status returns from wait() and
:> waitpid().
:Turns out that it is an 'anomaly' with solaris 2.6. In the forked child,
:your must reset the child handler like so:
:before calling system or open or backticks. Then, all is well. My partner
:found the solution by doing a search on deja news with the keywords 
:perl fork solaris system -1
:Matthew O. Persico
:"If you were supposed to understand it,
:we wouldn't call it code."
:------- end of forwarded message -------
: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About