- if ($file) {
- print STDERR "check completing batch\n";
- close $file or die $!;
- system "git update-ref --stdin <batch"
- and die $? < 0 ? $! : $?;
- }
+ return unless $file;
+
+ close $file or die $!;
+
+ print STDERR "check closing $batch ($count)\n";
+
+ await_task if @tasks >= $ncpus;
+
+ my $pid = fork // die $!;
+ if (!$pid) {
+ close STDIN;
+# seek STDIN,0,1;
+# flush STDIN;
+ open STDIN, "<", $batch or die $batch;
+ exec qw(git update-ref --stdin);
+ die $!;
+ }
+ print STDERR "check spawned $batch ($count) [$pid]\n";
+ push @tasks, [ $pid, $batch ];
+ $batch++;