From perldoc -f system:
You can check all the failure possibilities by inspecting $? like this:
if ($? == -1) { print "failed to execute: $!\n"; } elsif ($? & 127) { printf "child died with signal %d, %s coredump\ +n", ($? & 127), ($? & 128) ? 'with' : 'without +'; } else { printf "child exited with value %d\n", $? >> 8; }
Update: In the case of waitpid, this $? == -1 means that the child has been reaped automatically. I encountered this some time ago in a similar snippet. I do not know exactly why but a similar effect can be obtained by:
I cannot find the program I was working on but if I'm not mistaken, I got rid of all negative ones by simplifying the SIGCHILD handler. Store $? in the hash instead of testing it and test everything when all children are done.
In reply to Re: $? is -1???
by holo
in thread $? is -1???
by kscaldef
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |