- chdir $i_tmp or die "$i_tmp $!";
- initiator_expect { m/^dgit-remote-push-ready/ };
- for (;;) {
- initiator_expect { m/^(\S+)(?: (.*))?$/ };
- my ($icmd,$iargs) = ($1, $2);
- i_method "i_resp_", $icmd, $iargs;
- }
- };
+ }
+ $i_child_pid = open2(\*RO, \*RI, @cmd);
+ changedir $i_tmp;
+ initiator_expect { m/^dgit-remote-push-ready/ };
+ for (;;) {
+ my ($icmd,$iargs) = initiator_expect {
+ m/^(\S+)(?: (.*))?$/;
+ ($1,$2);
+ };
+ i_method "i_resp", $icmd, $iargs;
+ }
+
+ my $pid = $i_child_pid;
+ $i_child_pid = undef; # prevents killing some other process with same pid
+ printdebug "waiting for remote child $pid...";
+ my $got = waitpid $pid, 0;
+ die $! unless $got == $pid;
+ die "remote child failed $?" if $?;
+