-
-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
interp: use os.Pipe when StdIO or OpenHandler produce non-file stdins
A recent commit resolved the stdin draining issue with os/exec processes when stdin was created via a here-document, as those used buffers. Fix the same issue when stdin was provided via StdIO or Openandler, which are not guaranteed to provide an os.File. Much like the os/exec.Cmd.Stdin, we create a pipe and copy the contents from the original reader via a goroutine when not a file. This makes sense from an API standpoint: much like os/exec, the sh/interp API allows any io.Reader as stdin, but using an os.File will save a pipe and a goroutine as it can be used directly. Note that this requires cmd/gosh's tests for runInteractive to swap io.Pipe for os.Pipe, as otherwise we buffer stdin reads which cause the tests to hang.
- Loading branch information
Showing
6 changed files
with
76 additions
and
42 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
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