]> git.madduck.net Git - code/myrepos.git/blobdiff - mr

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

-j bugfixes
[code/myrepos.git] / mr
diff --git a/mr b/mr
index 2b1a36c22b21df656ca592cca16439fd029ad00d..1b66d82f484995a92786d328ba14e1013a8f784f 100755 (executable)
--- a/mr
+++ b/mr
@@ -569,15 +569,14 @@ sub action { #{{{
 } #}}}
 
 # run actions on multiple repos, in parallel
-my %jobs;
 sub mrs { #{{{
        $| = 1;
+       my @active;
        my @fhs;
        my @out;
        my $running=0;
        while (@fhs or @repos) {
                while ($running < $jobs && @repos) {
-                       $SIG{CHLD}='DEFAULT';
                        $running++;
                        my $repo = shift @repos;
                        my $pid = open(my $fh, "-|");
@@ -585,11 +584,9 @@ sub mrs { #{{{
                                open(STDERR, ">&STDOUT");
                                exit action($action, @$repo);
                        }
-                       $jobs{$pid}=$repo;
+                       push @active, $repo;
                        push @fhs, $fh;
                        push @out, "";
-                       reaper();
-                       $SIG{CHLD}=\&reaper;
                }
                my ($rin, $rout) = ('','', '');
                my $nfound;
@@ -605,6 +602,7 @@ sub mrs { #{{{
                                my $r = '';
                                if (sysread($fh, $r, 1024) == 0) {
                                        close($fh);
+                                       record($active[$i], $? >> 8);
                                        $fhs[$i] = undef;
                                        $running--;
                                        print $out[$i];
@@ -614,18 +612,13 @@ sub mrs { #{{{
                        }
                }
                while (@fhs and !defined $fhs[0]) {
+                       shift @active;
                        shift @fhs;
                        shift @out;
                }
        }
 } #}}}
 
-sub reaper { #{{{
-       while ((my $pid = waitpid(-1, &WNOHANG)) > 0) {
-               record($jobs{$pid}, $? >> 8) if exists $jobs{$pid};
-       }
-} #}}}
-               
 sub record { #{{{
        my $dir=shift()->[0];
        my $ret=shift;