Fix stdin blocking issue in service stop spinner using libc::poll#27
Merged
Fix stdin blocking issue in service stop spinner using libc::poll#27
Conversation
The stdin reader in stop_service_with_spinner used tokio::io::stdin() which spawns an internal blocking thread. When the container stopped gracefully (winning the select! race), aborting the tokio task did not terminate the underlying OS thread blocked on read(), preventing the process from exiting cleanly. Replace with a libc::poll-based approach that checks a cancellation AtomicBool every 100ms, allowing the blocking thread to exit promptly when the stop completes. https://claude.ai/code/session_01MwaCtnDsCDV5cmwhX8LGFP
Replace libc::poll-based stdin reader with a plain std::thread that communicates through a tokio::sync::oneshot channel. A plain thread is not part of tokio's blocking pool, so the runtime can shut down cleanly even if the thread is still blocked on read_line — the OS terminates it when the process exits. This removes the libc dependency while keeping the same fix for the terminal hang after graceful container shutdown. https://claude.ai/code/session_01MwaCtnDsCDV5cmwhX8LGFP
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
Replace tokio's async stdin with a blocking task using
libc::pollto fix a persistent blocking issue in the service stop spinner. The previous implementation usingtokio::io::stdin()would hang indefinitely because tokio's internal blocking thread persists even after task abort, preventing graceful shutdown.Changes
libcdependency (v0.2) to workspace and CLI packagespawn_blockingtask that useslibc::pollArc<AtomicBool>instead ofAbortHandleResult<std::io::Result<bool>>tobooluser_pressed_enterhelper to match new return typeType of Change
Testing
Describe how you tested your changes:
just test-rust)just lint)Checklist
Related Issues
Fixes stdin blocking issue in service stop command that prevented graceful shutdown.
https://claude.ai/code/session_01MwaCtnDsCDV5cmwhX8LGFP