On the one-liner, you are kicking out two child processes from the parent. Here's the code with indentation and decorations,
Unix does not guarantee the order of execution of parent and child. If the parent runs first, the second child may exit 4 before the first child does a normal exit by falling off the end of the program.if (fork) { #in parent if (fork) { #in parent still waitpid -1, undef; print "-- ", $?>>8, "\n"; } else { # in second child exit 4; } } # else ??? # parent and first child drop off the end
There is a good chance of your one-liner leaving zombie the child that waitpid didn't see. I/O generally takes more than one timeslice, so the remaining child is apt to end its brief life during print and shamble about waiting for somebody to read its exit status.
After Compline,
Zaxo
In reply to Re: Waitpid Woes
by Zaxo
in thread Waitpid Woes
by suaveant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |