fix: graceful runtime shutdown, ECHILD race fix, and SendInput cleanup#270
Merged
DorianZheng merged 2 commits intomainfrom Feb 15, 2026
Merged
fix: graceful runtime shutdown, ECHILD race fix, and SendInput cleanup#270DorianZheng merged 2 commits intomainfrom
DorianZheng merged 2 commits intomainfrom
Conversation
Three related fixes for clean process lifecycle management: 1. Runtime shutdown system: shutdown_sync() for atexit/Drop, SIGTERM handler in shim for graceful Guest.Shutdown RPC (qcow2 flush), detached boxes survive shutdown. CLI calls rt.shutdown() on exit. 2. Guest ECHILD fix: switch spawn_with_pipes() from tokio::process::Command to std::process::Command to avoid Tokio's orphan reaper racing with manual waitpid(). Added ECHILD safety net in wait_process(). 3. Host SendInput fix: spawn_stdin now accepts shutdown_token and wraps send_input in tokio::select! for clean cancellation during shutdown. Tests: 20 unit tests (shutdown_sync), 10 integration tests (shutdown), 4 integration tests (ECHILD/exec scenarios). All pass, clippy clean.
tokio's "full" meta-feature enables "process", which installs a global SIGCHLD handler via signal_hook. This handler eagerly reaps children with waitpid(-1, WNOHANG), racing with the guest's manual waitpid() in wait_process() and causing ECHILD errors. The guest never uses tokio::process — it uses std::process::Command (GuestExecutor) and libcontainer (ContainerExecutor). Replace "full" with only the features actually used: macros, rt-multi-thread, sync, io-util, net, fs, time.
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.
Summary
shutdown_sync()for atexit/Drop, SIGTERM handler in shim, detached boxes survive, CLI shutdown pathspawn_with_pipes()usesstd::process::Commandinstead of Tokio (avoids SIGCHLD handler race withwaitpid)spawn_stdinusesshutdown_tokenfor clean cancellation during shutdownTest plan
cargo test -p boxlite --lib rt_impl::tests)cargo test -p boxlite --test shutdown)cargo test -p boxlite --test execution_shutdown)cargo clippy -p boxlite --tests -- -D warnings)cargo fmt -p boxlite -- --check)boxlite exec "box" -- ls /completes without WARN/ERROR logsboxlite execruns succeed on same box