From ecae835d593673f0f721b4de19ce2718f8ecb3bb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 21 Oct 2007 01:23:29 -0400 Subject: [PATCH 1/1] need to manally reap children since it manually forks now --- mr | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mr b/mr index dd55fb8..76c629c 100755 --- a/mr +++ b/mr @@ -579,7 +579,8 @@ sub mrs { #{{{ my $repo = shift @repos; pipe(my $outfh, CHILD_STDOUT); pipe(my $errfh, CHILD_STDERR); - unless (my $pid = fork) { + my $pid; + unless ($pid = fork) { die "mr $action: cannot fork: $!" unless defined $pid; open(STDOUT, ">&CHILD_STDOUT") || die "mr $action cannot reopen stdout: $!"; open(STDERR, ">&CHILD_STDERR") || die "mr $action cannot reopen stderr: $!"; @@ -591,7 +592,7 @@ sub mrs { #{{{ } close CHILD_STDOUT; close CHILD_STDERR; - push @active, $repo; + push @active, [$pid, $repo]; push @fhs, [$outfh, $errfh]; push @out, ['', '']; } @@ -615,10 +616,11 @@ sub mrs { #{{{ $fhs[$i][$channel] = undef; if (! defined $fhs[$i][0] && ! defined $fhs[$i][1]) { + waitpid($active[$i][0], 0); print STDOUT $out[$i][0]; print STDERR $out[$i][1]; print "\n"; - record($active[$i], $? >> 8); + record($active[$i][1], $? >> 8); splice(@fhs, $i, 1); splice(@active, $i, 1); splice(@out, $i, 1); -- 2.39.5