Conversation
The removed NIF fallback could signal an unrelated process after the shepherd
reaped the child and the kernel reused its PID.
Route `NetRunner.Process.kill/2` and owner-down signals only through the
shepherd. Return `{:error, :transport_closed}` if the socket write fails.
Stop the watcher and clear its reference whenever NetRunner records an exit
status, including a synthetic status. The watcher stores only a numeric PID,
which is not a stable child identity.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
NetRunner caches the child’s numeric OS PID. If a request to the shepherd failed,
NetRunner.Processcould use the NIF to signal that PID directly.Once the shepherd has reaped the child, the kernel can assign the same PID to another process. Checking whether the shepherd port is closed does not prove that the cached PID still identifies the child.
Change
NetRunner.Process.kill/2now sends signals only through the shepherd:Owner-down cleanup uses the same shepherd-only path.
:okconfirms that NetRunner wrote the request to the socket. It does not confirm that the shepherd delivered the signal. If NetRunner has already recorded the child’s exit,kill/2returns{:error, :not_running}.Watcher behavior
The watcher remains a separate failure-recovery mechanism:
Stopping the watcher after every recorded exit prevents a later Process failure from triggering a signal through an obsolete PID.
Remaining limitation
The watcher’s crash-recovery probe still uses a numeric PID. The PID can theoretically be reused between its liveness check and the SIGTERM call. This PR limits direct PID signaling to that narrow failure path; eliminating the race completely would require a stable process handle such as a Linux pidfd.