Skip to content

Stop a leftover engine on macOS - #31

Merged
JaredP94 merged 3 commits into
mainfrom
fix/macos-orphan-reclaim
Nov 2, 2026
Merged

JaredP94 merged 3 commits into
mainfrom
fix/macos-orphan-reclaim

Conversation

@JaredP94

@JaredP94 JaredP94 commented Nov 2, 2026

Copy link
Copy Markdown
Owner

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's txt descriptor (the kernel's record, not argv). lsof/ss run from fixed system paths, never PATH, since the PID they return is the one signalled. Both sides of the ownership comparison resolve symlinks (/private/var vs /var).

Adapted from NVIDIA#136 (NVIDIA#17, NVIDIA#47).

Validation

  • go test ./... in nvpair-engine-manager on macOS arm64: the previously skipped TestUninstallTerminatesRunningInstance and the reclaim tests now run and pass, including the external same-name process being left alone.
  • GOOS=linux / GOOS=windows go vet and Linux test build.

Risk

The kill still requires an exact image match. engine-manager 1.4.0.

Checklist

  • I have read the Contributing Guidelines.
  • Every commit is signed off (git commit -s), certifying the Developer Certificate of Origin.
  • New or existing tests cover the change.
  • Relevant documentation is updated.
  • I checked the diff, changed filenames, and commit messages for credentials, private data, internal URLs, internal issue identifiers, and generated artifacts.
  • I recorded the validation commands and results above.
  • I bumped any affected component in 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 bump services/versions.json, so the second one merged will need a trivial conflict resolution there.

JaredP94 and others added 3 commits November 2, 2026 20:48
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
JaredP94 force-pushed the fix/macos-orphan-reclaim branch from e0f838a to 79cdb7d Compare November 2, 2026 18:50
@JaredP94
JaredP94 merged commit 359b95a into main Nov 2, 2026
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