I've played with the code a bit more, and it's failing for me as well. But not always. How often it fails, depends on the number of spawned children. Trying 1, 2, 3, 4, and 5 children, each 10 times, I get success rates of 100%, 90%, 40%, 10% and 0%.
Something is wrong, but I do not know what. I'll have to consult Stevens. | [reply] |
my $q;
$q=<STDIN>;
print "Received(child $$): $q\n";
it stopped hanging on close($fd).
When I traced what is happening when it hangs, it looks like parent is waiting waitpid(..) (close($fd) on pipe is supposed to do that), while child blissfully unaware is running read...
Now I can safely go and try to understand merlyn's code.
| [reply] [d/l] [select] |