@ -3191,13 +3191,22 @@ background_import_then_checkpoint () {
exec 9<>V.output
exec 9<>V.output
rm V.output
rm V.output
(
git fast-import $options <&8 >&9 &
git fast-import $options <&8 >&9 &
echo $! >V.pid
echo $! >&9
wait $!
echo >&2 "background fast-import terminated too early with exit code $?"
# Un-block the read loop in the main shell process.
echo >&9 UNEXPECTED
) &
sh_pid=$!
read fi_pid <&9
# We don't mind if fast-import has already died by the time the test
# We don't mind if fast-import has already died by the time the test
# ends.
# ends.
test_when_finished "
test_when_finished "
exec 8>&-; exec 9>&-;
exec 8>&-; exec 9>&-;
kill $(cat V.pid) && wait $(cat V.pid)
kill $sh_pid && wait $sh_pid
kill $fi_pid && wait $fi_pid
true"
true"
# Start in the background to ensure we adhere strictly to (blocking)
# Start in the background to ensure we adhere strictly to (blocking)
@ -3217,6 +3226,9 @@ background_import_then_checkpoint () {
then
then
error=0
error=0
break
break
elif test "$output" = "UNEXPECTED"
then
break
fi
fi
# otherwise ignore cruft
# otherwise ignore cruft
echo >&2 "cruft: $output"
echo >&2 "cruft: $output"
@ -3229,7 +3241,7 @@ background_import_then_checkpoint () {
}
}
background_import_still_running () {
background_import_still_running () {
if ! kill -0 "$(cat V.pid)"
if ! kill -0 "$fi_pid"
then
then
echo >&2 "background fast-import terminated too early"
echo >&2 "background fast-import terminated too early"
false
false