fix(cli): stop box before hard-exit on non-zero run exit code#622
Open
G4614 wants to merge 1 commit into
Open
Conversation
`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>
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.
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 runintegration tests, each verified two-sided (fix reverted vs applied) on currentmain:test_run_exit_code_125/test_run_exit_code_custom—run --rm … exit <non-zero>test_run_signal_exit_code_{sigint,sigkill,sigterm}— foreground command killed by signaltest_run_python_error_handling— non-zero exit via a Python errorrun.rsreverted)boxlite-shimafter the command exitsprocess::exitPerTestBoxHomedrop guard (#604)live shim(s): [pid]Pre-fix, a non-zero command exit took the
std::process::exitshortcut 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.