Skip to content

Send container machine run forced-exit diagnostic to stderr - #2073

Open
vyncint wants to merge 1 commit into
apple:mainfrom
vyncint:fix/machine-run-stderr-diagnostic
Open

Send container machine run forced-exit diagnostic to stderr#2073
vyncint wants to merge 1 commit into
apple:mainfrom
vyncint:fix/machine-run-stderr-diagnostic

Conversation

@vyncint

@vyncint vyncint commented Aug 5, 2026

Copy link
Copy Markdown

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

Part of #642.

container machine run installs a SignalThreshold handler to report the forced exit after three SIGINT/SIGTERMs, but emits that diagnostic with print(), so it goes to stdout.

The identical handler in the sibling commands uses log.warning(), which the CLI routes to stderr through StderrLogHandler:

The handler is only installed when !tty — precisely when stdout is likely a pipe or a file — so the diagnostic is interleaved into the machine process's redirected output rather than kept on the terminal.

This routes the message to stderr, matching the sibling commands. let log = self.log is bound before the closure for the same reason it is in those two: SignalThreshold.start takes a @Sendable @escaping closure.

Testing

  • Tested locally

  • Added/updated tests

  • Added/updated docs

  • swift build -c debug -Xswiftc -warnings-as-errors -Xswiftc -enable-testing — clean

  • make test — 613 tests in 71 suites passed

  • swift format lint --strict --configuration .swift-format-nolint on the changed file — clean

  • Confirmed the stream routing with the built binary: logger output goes to stderr (container image load -i /nonexistent writes only to stderr) and print() output goes to stdout (container --version).

I did not exercise the three-signal path end to end, as that needs a booted container machine; the change is a like-for-like swap to the logger the sibling commands already use on that same code path.

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