Created attachment 181726 [details]
Patch to not wait on our own pid.
pwait will deadlock when passed its own PID. I experienced this when kern.randompid was set with poudriere. The code was more or less this:
if do_the_thing ends before pwait starts, and do_the_thing and pwait get the same pid, pwait waits indefinitely.
I've attached a patch to warn and exit immediately if pwait is told to wait on its own pid.
Hmm, this is sort of a workaround for the shell reaping zombies quickly and not providing the script with a good way to detect this.
If code is executed like
sh -c '...; exec pwait $$'
it arguably should deadlock.
The patch seems a simple way to avoid the deadlock in poudriere, though.
(In reply to Jilles Tjoelker from comment #1)
Yeah, a literal reading of the documentation implies that it should hang. Personally I'd interpret pwait's own PID as invalid, though that's up for debate.
Is there any update regarding on this bug?