Repository navigation
repro-hostgemm-lock: the setsid comment names the session, not $! (follow-up to #2472) - #2477
Conversation
…llow-up to #2472) #2472 removed `setsid` and its comment says setsid "makes `$!` the setsid pid". In this script that is not what happens: util-linux setsid forks only when the caller is a process-group leader, and a `&` job in a non-interactive script (no `set -m`) is not one, so setsid execs in place and `$!` IS the server. non-interactive: setsid sleep 301 & -> $! comm=sleep, kill $! -> gone with set -m: setsid sleep 302 & -> $! is the forking parent, kill $! -> sleep survives Removing setsid is still right, for the other reason: it put the server in its own session, so a script killed without its EXIT trap left the server with no SIGHUP and PPID 1. The comment now says that, so a later reader does not "fix" the trap and bring setsid back. Co-Authored-By: Claude Opus 5.5 <[email protected]>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
VERDICT: READY Correcting a comment that states the wrong mechanism is worth a PR on its own, and this one is exemplary in what it does not do: "Comment only; the code is unchanged." A wrong mechanism in a comment is worse than no comment — it survives review, gets cited in future discussions, and is believed precisely because someone bothered to write it down. Two things I would put in the corrected text, since the point of writing it is that the next reader does not repeat the wrong model:
If #2472's own description already carries that reasoning, one pointer is enough. |
Follow-up to #2472, which merged at 03:36:55Z with a comment that gives the wrong mechanism. Comment only; the code is unchanged.
What the comment said, and what happens
The comment says
setsid"makes$!the setsid pid, sokill $PIDbelow would miss the server". In this script that is not what happens. util-linuxsetsidforks only when the caller is a process-group leader. A&job in a non-interactive script (this one hasset -u, noset -m) is not one, sosetsidexecs in place and$!is the server.Measured with util-linux 2.41.3:
Why removing
setsidwas still rightsetsidput the server in its own session. When the script dies without running its EXIT trap (SIGKILL, an orchestrator stop, a closed terminal), a server outside the session gets no SIGHUP and survives with PPID 1. That is the orphan class. Withoutsetsid, the server shares the script's session and goes down with it.The comment now says that. The risk with the old wording is that a later reader decides the problem was
$!, "fixes" the trap, and putssetsidback.Verified
bash -n tools/repro-hostgemm-lock.shis clean. The diff is 6 comment lines in one file; no code changed.🤖 Generated with Claude Code