Add CloseStdin to task

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2017-05-31 15:53:42 -07:00
parent 6aeeefe2b2
commit 9890bed1e1
3 changed files with 120 additions and 0 deletions

26
io.go
View File

@@ -54,6 +54,32 @@ func BufferedIO(stdin, stdout, stderr *bytes.Buffer) IOCreation {
}
}
func NewIO(stdin io.Reader, stdout, stderr io.Writer) IOCreation {
return func() (*IO, error) {
paths, err := fifoPaths()
if err != nil {
return nil, err
}
i := &IO{
Terminal: false,
Stdout: paths.out,
Stderr: paths.err,
Stdin: paths.in,
}
set := &ioSet{
in: stdin,
out: stdout,
err: stderr,
}
closer, err := copyIO(paths, set, false)
if err != nil {
return nil, err
}
i.closer = closer
return i, nil
}
}
// Stdio returns an IO implementation to be used for a task
// that outputs the container's IO as the current processes Stdio
func Stdio() (*IO, error) {