Re: [PATCH] t9300-fast-import: don't hang if background fast-import exits too early
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 1, 2019, 15:38 UTC
- Message-ID
- <xmqq36e412er.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20191201093148.GH23183@szeder.dev>
SZEDER Gábor <szeder.dev@gmail.com> writes:
Show 21 quoted lines
>> > - test_when_finished " >> > + test_when_finished ' >> > exec 8>&-; exec 9>&-; >> > - kill $(cat V.pid) && wait $(cat V.pid) >> > - true" >> > + kill $(cat V.sh.pid) && wait $(cat V.sh.pid) >> > + kill $(cat V.fi.pid) && wait $(cat V.sh.pid) >> > + true' >> >> The original interpolates the PID of the fast-import when >> "when-finished" program is registered, so it is OK if somebody else >> removed V.pid file; the new one interpolates when "when-finished" >> program is run, reading from V.??.pid, so somebody needs to make >> sure these pid files will stay around. I do not think it is an >> issue as I suspect we've left it to the global clean-up procedure >> that removes the trash directory to remove the pid file. > > In the original the same shell process starts 'git fast-import', > writes its pidfile, and registers the test_when_finished commands, so > we can be sure that the pid file is already present when the shell > runs the $(cat V.pid) command substitutions.
Yes. It also means that V.pid file was not very useful in the when-finished handler in the original. We could have just used a shell variable.
Show 7 quoted lines
> With this patch that's not the case anymore, because the background > subshell starts 'git fast-import' and writes the pidfile, but the main > shell process registers the test_when_finished commands. IOW these > two shell processes are racing, and it's possible that the > test_when_finished command is executed before the background subshell > can write the pidfile. So double quotes around the block of > test_when_finished commands are not good.
Oh, I was not questioning that. I wanted to make sure, and I was doing so aloud, that these files are
(1) created way before, and (2) left on the filesystem
when-finished handler actually runs, because the original did not need any guarantee for (2), but now the sq version does.