Repository navigation
Stop a leftover engine on macOS - #31
Merged
Merged
Conversation
Before terminating an engine it lost the process handle to (after a crash, a force quit or a worker restart), the engine manager confirms the process on its managed port is the binary it manages. The image lookup read /proc, which macOS does not have, so the check failed closed every time and a stop or uninstall of PAIR's own Ollama was refused with "running under external management"; the reclaim tests skipped on macOS for the same reason. macOS now resolves the image from lsof's txt descriptor, the kernel's record of the running executable. lsof and ss are run from fixed system locations, never through PATH, since the PID they return is the one a stop signals. Both sides of the ownership comparison resolve symlinks, because macOS reports /private/var/... for a configured /var/.... Adapted from NVIDIA#136 (issues NVIDIA#17 and NVIDIA#47). Co-authored-by: Terve <ntervalon@nvidia.com> Signed-off-by: Jared Ping <13906915+JaredP94@users.noreply.github.com>
…nt ownership Review follow-up. Resolving the install directory in the shared containment helper let an install directory that is itself a link claim whatever it points at, and turned the documented-lexical cli_roots coverage into a resolved one. Containment is lexical again. Stopping or removing an engine now uses isOwnedInstallPath, which requires the binary inside the install directory both as written and with links resolved, and only the running image comparison resolves links (for macOS /var vs /private/var). Signed-off-by: Jared Ping <13906915+JaredP94@users.noreply.github.com>
…ectory Review follow-up. A binary spelled through an install directory that is itself a link passed both containment checks. PAIR creates that directory, so a link there leads somewhere PAIR did not install into; ownership is now refused for it. Links above it (/var on macOS) still work. Signed-off-by: Jared Ping <13906915+JaredP94@users.noreply.github.com>
JaredP94
force-pushed
the
fix/macos-orphan-reclaim
branch
from
November 2, 2026 18:50
e0f838a to
79cdb7d
Compare
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.
Description
Before killing an engine it lost the handle to (crash, force quit, worker restart), the engine manager confirms the process on its managed port runs its own binary. The image lookup read
/proc, which macOS lacks, so the check always failed closed: stopping or uninstalling PAIR's own leftover Ollama was refused with "running under external management", and the reclaim tests silently skipped on macOS.macOS now reads the image from
lsof'stxtdescriptor (the kernel's record, not argv).lsof/ssrun from fixed system paths, neverPATH, since the PID they return is the one signalled. Both sides of the ownership comparison resolve symlinks (/private/varvs/var).Adapted from NVIDIA#136 (NVIDIA#17, NVIDIA#47).
Validation
go test ./...innvpair-engine-manageron macOS arm64: the previously skippedTestUninstallTerminatesRunningInstanceand the reclaim tests now run and pass, including the external same-name process being left alone.GOOS=linux/GOOS=windowsgo vetand Linux test build.Risk
The kill still requires an exact image match. engine-manager 1.4.0.
Checklist
git commit -s), certifying the Developer Certificate of Origin.services/versions.json, and described user-visible changes above so they reach the release notes.Part of the upstream issue/PR review. Each branch is independent off
main; they all bumpservices/versions.json, so the second one merged will need a trivial conflict resolution there.