Taylor, Andrew (ASPIRE) wrote:
> OK, I'm clearly being dense here then.  My understanding was that the
> "$?" contained the status of the pid returned by waidpid.  
> 
> If waitpid returned a pid from some other process (i.e. not one of my
> children) that had failed (i.e return status other than 0) then wouldn't
> my test abort the script when it wouldn't need to (as the process that
> failed wasn't one of my children) before it got to the redo?
> 
> Or have I firmly grasped the wrong end of the stick?

On some systems, waitpid may return something rather than a child pid or
-1.  This would happen when the wait was interrupted by something other
than a child death.  Most likely, it would be zero.

The return status, $?, is a 16-bit word of three packed values.  See
`perldoc perlvar` and search for /\$\?/.  It should be set to a non-zero
value by the child if the child does not terminate successfully.  Most
UNIX commands do this; most user-written scripts do not.  Also, Windows
ignores the return value and always returns zero.

$? should not change unless a child process died.


-- 
Just my 0.00000002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

I like Perl; it's the only language where you can bless your
thingy.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to