http://qs321.pair.com?node_id=881361


in reply to Re: Working with other processes and programs
in thread Working with other processes and programs

Other thoughts to consider when evaluating return codes can include how the process was created. For example, if one uses the IPC::Open3 module to run the external command and the processes (pid) is killed using 'kill( 9, $pid )' the '$? >> 8' evaluation may result in 0. This is probably not the expected value, seeing how the processes was terminated. However, if one inspects the '${^CHILD_ERROR_NATIVE}' the result would show an exit value of 9.

According to PerlDoc:

If the filehandle came from a piped open, close returns false if one of the other syscalls involved fails or if its program exits with non-zero status. If the only problem was that the program exited non-zero, $! will be set to 0. Closing a pipe also waits for the process executing on the pipe to exit--in case you wish to look at the output of the pipe afterwards--and implicitly puts the exit status value of that command into $? and ${^CHILD_ERROR_NATIVE}.

http://search.cpan.org/~jesse/perl-5.12.2/pod/perlfunc.pod

Admittedly this may be a result of how things are terminated, closed and cleaned up. But it is a thought to consider.

  • Comment on Re^2: Working with other processes and programs