if (!open($handles[$i], "|-") { ...close $handles[0..$i-1]... child(); exit(0); }