Cleanup FIFOs on error.
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
parent
bb39d1d982
commit
73735c4dba
7
io.go
7
io.go
@ -59,11 +59,16 @@ func NewIO(stdin io.Reader, stdout, stderr io.Writer) IOCreation {
|
|||||||
|
|
||||||
// NewIOWithTerminal creates a new io set with the provied io.Reader/Writers for use with a terminal
|
// NewIOWithTerminal creates a new io set with the provied io.Reader/Writers for use with a terminal
|
||||||
func NewIOWithTerminal(stdin io.Reader, stdout, stderr io.Writer, terminal bool) IOCreation {
|
func NewIOWithTerminal(stdin io.Reader, stdout, stderr io.Writer, terminal bool) IOCreation {
|
||||||
return func(id string) (*IO, error) {
|
return func(id string) (_ *IO, err error) {
|
||||||
paths, err := NewFifos(id)
|
paths, err := NewFifos(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
if err != nil && paths.Dir != "" {
|
||||||
|
os.RemoveAll(paths.Dir)
|
||||||
|
}
|
||||||
|
}()
|
||||||
i := &IO{
|
i := &IO{
|
||||||
Terminal: terminal,
|
Terminal: terminal,
|
||||||
Stdout: paths.Out,
|
Stdout: paths.Out,
|
||||||
|
Loading…
Reference in New Issue
Block a user