Skip to content

fix(cli): stop box before hard-exit on non-zero run exit code#622

Open
G4614 wants to merge 1 commit into
boxlite-ai:mainfrom
G4614:fix/cli-run-rm-abnormal-exit
Open

fix(cli): stop box before hard-exit on non-zero run exit code#622
G4614 wants to merge 1 commit into
boxlite-ai:mainfrom
G4614:fix/cli-run-rm-abnormal-exit

Conversation

@G4614
Copy link
Copy Markdown
Contributor

@G4614 G4614 commented May 29, 2026

when the box killed badly (non-zero return code), the shim process should be released manually

appeared because of #604

Test plan

The abnormal-exit boxlite run integration tests, each verified two-sided (fix reverted vs applied) on current main:

  • test_run_exit_code_125 / test_run_exit_code_customrun --rm … exit <non-zero>
  • test_run_signal_exit_code_{sigint,sigkill,sigterm} — foreground command killed by signal
  • test_run_python_error_handling — non-zero exit via a Python error
observed pre-fix (run.rs reverted) post-fix
boxlite-shim after the command exits live — orphaned by process::exit gone — stopped first
PerTestBoxHome drop guard (#604) panicslive shim(s): [pid] clean
test result all 6 FAIL all 6 PASS

Pre-fix, a non-zero command exit took the std::process::exit shortcut that bypasses the box teardown the success path runs on return, leaking the microVM's shim (the source of the "orphan shims in /tmp" that motivated #604). Post-fix the box is explicitly torn down before the process exits with the shell-mapped code.

`boxlite run` propagated a non-zero command exit via std::process::exit,
which skips Drop and the box's async auto-stop/auto-remove — leaking the
box's shim as a live host process. The success path tears the box down via
normal teardown when run() returns, but the non-zero path never reached it.

Explicitly stop the box (kills the shim; removes it when --rm) before
std::process::exit. Fixes the abnormal-exit run integration tests
(exit_code_125/custom, signal_exit_code_{sigint,sigkill,sigterm},
python_error_handling) that tripped PerTestBoxHome's live-shim guard.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@G4614 G4614 marked this pull request as ready for review May 29, 2026 06:20
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