stats: restore terminal when streaming is interrupted by a signal#1355
Open
Otoru wants to merge 1 commit intoapple:mainfrom
Open
stats: restore terminal when streaming is interrupted by a signal#1355Otoru wants to merge 1 commit intoapple:mainfrom
Otoru wants to merge 1 commit intoapple:mainfrom
Conversation
dcantah
reviewed
Mar 27, 2026
Member
|
@Otoru We require all commits be signed (gpg/ssh) |
53678f9 to
b79b414
Compare
Author
|
@dcantah, thanks for explaining. Fixed. |
Member
|
@Otoru Can you remove the unit tests? We can add separately |
b79b414 to
eef85e7
Compare
Author
|
@dcantah of course |
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.
Type of Change
Motivation and Context
When
container statsruns in streaming mode, pressing Ctrl+C sends SIGINT directly to the process before Swift can run thedeferblock responsible for restoring the terminal. This leaves the alternate screen buffer active and the cursor hidden after exit.Fix this by wrapping the streaming loop in a
withThrowingTaskGroupthat races the work against anAsyncSignalHandlerfor SIGINT and SIGTERM. When a signal arrives, the group is cancelled through normal Swift unwinding, allowing thedeferto execute and restore the terminal correctly. This follows the same pattern used inBuildCommand.runStreaming,collectStats,printStatsTable, andclearScreenare promoted to static methods since none of them read instance state, which is required to safely capture only thecontainersvalue in the task closure under Swift 6 strict concurrency.Fixes #1351
Testing