Skip to content

fix(daemon): launcher.go call sites still use fragile Getpgid rediscovery path #861

Description

@PierrunoYT

Context

Follow-up from review of PR #774, which introduced TerminateProcessGroup/terminateOwnedProcess specifically to avoid the fragile Getpgid rediscovery in TerminateProcessTree (documented at internal/execution/process_unix.go:62-69: on Darwin, Getpgid can return ESRCH once an unreaped group leader has exited, even though live descendants remain in the group it configured, causing TerminateProcessTree to silently fall back to signalling only the dead leader PID and leaving descendants running).

Two call sites still hold an *exec.Cmd that went through background.ConfigureChildProcessGroup (so launch-time group identity is known) but call background.TerminateProcess(pid), which routes through the fragile rediscovery path instead of the stronger primitive:

  • internal/daemon/launcher.go:77 (execWorker.Kill)
  • internal/daemon/launcher.go:163 (cmd.Cancel)

internal/specialist/exec.go:493 is correctly left alone since it only has a bare PID (no launch-time group knowledge to leverage).

Proposed fix

Since both call sites hold the *exec.Cmd, they can call background.TerminateCommand(cmd) (or a comparable helper that uses terminateOwnedProcess) instead of background.TerminateProcess(cmd.Process.Pid), so they take the launch-time-invariant path rather than rediscovery.

Not blocking; pre-existing behavior, same shape as the daemon-start path #774 fixed.

Activity

  1. added a commit that references this issue on Sep 1, 2026
    77e439a
  2. added
    bugSomething isn't working
    issue-approvedReviewed and approved by the core team; community PRs may implement this issue.
    on Sep 8, 2026
  3. Vasanthdev2004 commented on Sep 8, 2026

    @Vasanthdev2004
    Collaborator

    Labelled and approved. I checked the open PRs that touch the daemon (#927, #987) and neither reaches these two call sites, so nothing is in flight for this. The fix is what the issue already prescribes: the two sites hold an *exec.Cmd that went through ConfigureChildProcessGroup, so they should call the group primitive rather than TerminateProcess(pid) and its rediscovery path. A regression that makes the leader exit unreaped before termination, then asserts the descendants are gone, is the test that proves it.

  4. Vasanthdev2004 commented on Sep 12, 2026

    @Vasanthdev2004
    Collaborator

    Back in the pool, and still valid on current main.

    This came up in an audit of open issues whose only linked pull request had closed, which made them look covered to a query while nobody was actually working them. The earlier attempt closed without landing, so this is open for a fresh one.

    I verified the problem still exists rather than assuming it, and the audit verdict was independently re-checked before I posted this. The label is already on, so a PR implementing it can merge on review.

  5. added a commit that references this issue on Sep 26, 2026
    1d034d8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't workingissue-approvedReviewed and approved by the core team; community PRs may implement this issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions