Skip to content

fix: orphaned background job exits the same on macOS - #158

Merged
natevick merged 2 commits into
mainfrom
natevick/sel-394-macos-orphan
Nov 22, 2026
Merged

natevick merged 2 commits into
mainfrom
natevick/sel-394-macos-orphan

Conversation

@natevick

Copy link
Copy Markdown
Contributor

On macOS, a background job orphaned from a live terminal now exits 9 with the write error, as it does on Linux. It used to exit 130, as if the user had interrupted it.

Linear: SEL-394.

What changed

macOS now decides "the reader is gone" by polling stdout, the same way Linux does, instead of using whether stdout was a terminal at startup. It's a one-line change plus a test.

Checks, on a real arm64 Mac

  • Orphaned job on a live terminal: exit 9 with the write error, 10 of 10. The base commit exits 130.
  • Terminal closes mid-run: exits as interrupted, 20 of 20.
  • Terminal already closed at start: exits as interrupted, 20 of 20, across both stderr layouts, with every write returning EIO.
  • The existing M4 row: 10 of 10.
  • The new unit test fails on the base commit and passes here.

On Linux: go vet on all three platforms, go test -race, and golangci-lint 1.64.8 pass.

Not established

  • The new test only runs on a Mac, so CI doesn't run it.
  • The orphaned-job case was shown on one Mac, under sandbox-exec.
  • A write already in flight at the instant the terminal closes was not observed.

🤖 Generated with Claude Code

https://claude.ai/code/session_0186m4FrY9RHAiNN1uxztLCp

Nate Vick and others added 2 commits November 22, 2026 11:37
On darwin, eioMeansReaderGone returned the startup terminal flag, so any
EIO on a terminal stdout was read as "the reader left" and the run exited
130. A background job orphaned on a live terminal gets EIO too (a plain
writer in the same setup gets a real EIO, 10 of 10 in the sel378 macOS
test bed), so it exited 130 where Linux exits 9 with the write error.

Darwin now asks readerGone(f), as Linux does. The sel378 K4 probe showed
the macOS pty poll answers correctly 20 of 20 with the master open (not
gone) and closed (gone). Windows is unchanged and the terminal parameter
stays in the signature.

The new darwin test checks the helper against a live and a closed pipe
reader with terminal true and false. It is red on the old body in both
cases. CI runs on ubuntu only, so it compiles under the darwin vet but
only executes on a Mac.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0186m4FrY9RHAiNN1uxztLCp
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_0186m4FrY9RHAiNN1uxztLCp
@natevick
natevick marked this pull request as ready for review November 22, 2026 21:56
@natevick
natevick merged commit cc77b0d into main Nov 22, 2026
1 check passed
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