local $SIG{ALRM} = sub { die "alarm\n" };
alarm(30);
$content_type = <CHILD>;
- while (my $line = <CHILD>) {
- $status .= $line;
+ while (<CHILD>) {
+ $status .= $_;
}
alarm(0);
};
# The child didn't get back to us in time, kill them off.
if ($@) {
- kill 15, $pid
+ my $result;
+ do {
+ kill 9, $pid;
+ $result = waitpid($pid, WNOHANG);
+ } while $result > 0;
}
+ $| = 0;
return ($content_type, $status);
} else {
sub pipe_from_fork ($) {
my $parent = shift;
+ $SIG{CHLD} = 'IGNORE';
pipe $parent, my $child or die;
my $pid = fork();
die "fork() failed: $!" unless defined $pid;