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

User SIG{CHLD} handler confusing perl internals

From:
Tom Christiansen
Date:
November 12, 1999 06:18
Subject:
User SIG{CHLD} handler confusing perl internals
Message ID:
199911121417.HAA09911@jhereg.perl.com
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.

--tom

:From: "Matthew O. Persico" <mpersico@erols.com>
: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: <382B6B9B.848FEF99@erols.com>
:References: <199911120021.TAA06438@junior.apk.net>
:
:"Brandon S. Allbery KF8NH" wrote:
:> 
:> In article <382A5605.1D76709C@erols.com>, 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:
:
:$SIG{CHLD} = "DEFAULT"
:
: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 -------
:




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About