Skip to content

fix(kill): ignore a parent PID that a newer process reused - #94

Merged
vishr merged 3 commits into
mainfrom
fix/kill-stale-parent-links
Oct 31, 2026
Merged

vishr merged 3 commits into
mainfrom
fix/kill-stale-parent-links

Conversation

@vishr

@vishr vishr commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Windows keeps the PID of an exited parent, and a newer, unrelated process can reuse it. ProtectedReason followed raw PPIDs upward, so it could treat that process as Driga's parent and refuse to stop it. TestChatCommandsBuiltBinary failed this way on Windows CI: "PID 732: Driga, Chat, or an ancestor/descendant is protected" for the test's own fixture.

Protection is now computed once per snapshot and errs toward protecting:

  • An ancestor walk stops only at a Windows parent that provably started after its child. Unix keeps every link.
  • Descendants follow every parent link, so a broker root that exited still protects its children.
  • If Driga is missing from the snapshot, its parent's ancestry is still protected.
  • A broker root is skipped only when a clearly newer process (over one second later) holds its PID.
  • Identity checks run before the graph is built; process selection builds the set once.

Tests cover both platform modes on every OS.

vishr added 3 commits October 31, 2026 10:29
ProtectedReason walks parent links to protect Driga's and Chat's ancestors
and descendants. Windows keeps the PID of an exited parent, and a newer,
unrelated process can reuse it, so the walk could mark that process as
Driga's parent and refuse to stop it. TestChatCommandsBuiltBinary failed
this way on Windows CI: "PID 732: Driga, Chat, or an ancestor/descendant is
protected" for the test's own fixture.

A parent link now counts only when the parent started no later than the
child; a missing or unknown start time keeps the link.
Address review: reuse derive.ProcIndex for parent links, so only Windows
ignores a reused parent PID and Unix keeps every live link. Driga's own
ancestors come from the index rather than an unchecked os.Getppid, a broker
root whose PID a newer process reused no longer protects it, and process
selection builds the protected set once per snapshot.
Address review: descendants follow every parent link again, so a broker
root that exited still protects its children; an ancestor walk stops only
at a Windows parent that provably started after its child; a missing self
still protects the parent's ancestry; a broker root is skipped only when a
clearly newer process holds its PID; nested roots are walked once; identity
checks run before the graph is built. Tests run both platform modes.
@vishr
vishr merged commit f8333f9 into main Oct 31, 2026
6 checks passed
@vishr
vishr deleted the fix/kill-stale-parent-links branch October 31, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant