in reply to $? is -1???
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: $? is -1???
by kscaldef (Pilgrim) on Jun 20, 2004 at 19:53 UTC |