in reply to Forked pipe deadlock
That is, when the parent forks child #2, it will inherit the parent's pipe to child #1, and that is what is keeping child #1 from seeing EOF.for (my $i = 3; $i >= 0; $i--) { close($handles[$i]); }
One solution is to explicit close those handles in the new children:
Update: Corrected index bounds - thanks psini!if (!open($handles[$i], "|-") { ...close $handles[0..$i-1]... child(); exit(0); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Forked pipe deadlock
by almut (Canon) on May 25, 2008 at 21:33 UTC | |
|
Re^2: Forked pipe deadlock
by psini (Deacon) on May 25, 2008 at 20:55 UTC | |
|
Re^2: Forked pipe deadlock
by Anonymous Monk on May 25, 2008 at 21:35 UTC |