if(!open($handles[$i], '|-')) { # child process foreach $handle (@handles) { defined($handle) && close($handle); } child(); exit 0; }