diff options
Diffstat (limited to 'src/os/exec/exec.go')
| -rw-r--r-- | src/os/exec/exec.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/os/exec/exec.go b/src/os/exec/exec.go index 67dd379b71..0dac34447f 100644 --- a/src/os/exec/exec.go +++ b/src/os/exec/exec.go @@ -490,6 +490,12 @@ func lookExtensions(path, dir string) (string, error) { // After a successful call to Start the Wait method must be called in // order to release associated system resources. func (c *Cmd) Start() error { + // Check for doubled Start calls before we defer failure cleanup. If the prior + // call to Start succeeded, we don't want to spuriously close its pipes. + if c.Process != nil { + return errors.New("exec: already started") + } + started := false defer func() { c.closeDescriptors(c.childIOFiles) @@ -519,9 +525,6 @@ func (c *Cmd) Start() error { } c.Path = lp } - if c.Process != nil { - return errors.New("exec: already started") - } if c.ctx != nil { select { case <-c.ctx.Done(): |
