fix: return terminal control to parent on quit#142
Open
youdie006 wants to merge 1 commit into
Open
Conversation
In stdin mode (e.g. kubectl logs -f ... | gonzo), readStdinAsync's inner goroutine blocks on a read of os.Stdin that never sees EOF on a live pipe, so on 'q' the context is cancelled but the blocked read keeps holding the TTY/pipe fd and the parent (K9s) only regains control after a follow-up Ctrl-C. Close the stdin reader on quit (sync.Once) so the blocked read returns immediately and the goroutine exits, and return on EOF to fix a busy-spin. Adds a teardown test. (Incidental: gofmt import reorder in the touched file.) Closes control-theory#58
Contributor
|
Hey! thanks for the PR! |
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
In stdin mode (e.g.
kubectl logs -f ... | gonzo, the K9s plugin), pressingqcancelled the app context but left an inner goroutine blocked on a read ofos.Stdin. On a live pipe that read never sees EOF, so it keeps holding the TTY/pipe fd and the parent (K9s) only regains control after a follow-up Ctrl-C — the black-screen-until-keypress behavior in #58.Fix
On quit, close the stdin reader (guarded by
sync.Once) so the blocked read returns immediately and the goroutine exits, returning control to the parent without Ctrl-C. Alsoreturnon EOF (the old code re-spawned the scan and busy-spun). Adds a unit test for the teardown seam (a blocking reader that unblocks on Close).(Incidental: the touched file picked up a
gofmtimport reorder.)Closes #58