-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/record: cancel reading from stdin when shell exits
The only way to io.Copy(dst, os.Stdin) returns in raw mode is when io.Copy tries to read a character from stdin and find that dst is no longer valid. For our use here, that presents a problem. Users expect the input to close when they exit the shell. We can't get an extra input here to unblock io.Copy when it is reading from stdin. Enter, cancelreader. We wrap os.Stdin with a cancel reader that can be preempted from another go-routine by calling Cancel() on the cancel reader. The implementation of the cancel reader is platform dependent, but the pkg should work across linux, osx and windows. @creack also points out an alternative way to ensure we don't block on io.Copy reads here: creack/pty#188 (comment)
- Loading branch information
Showing
3 changed files
with
61 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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