mirror of
https://github.com/golang/go
synced 2024-11-02 13:42:29 +00:00
os/exec: avoid leaking a process in TestDoubleStartLeavesPipesOpen
Updates #52580. For #50436. Change-Id: I0929055ffca1ca429f6ebec7d877f4268bd1fda2 Reviewed-on: https://go-review.googlesource.com/c/go/+/436656 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Benny Siegert <bsiegert@gmail.com>
This commit is contained in:
parent
4a0a2b33df
commit
ce3a5c0d10
1 changed files with 7 additions and 0 deletions
|
@ -1108,9 +1108,16 @@ func TestDoubleStartLeavesPipesOpen(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := cmd.Start(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
if err := cmd.Wait(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
})
|
||||
|
||||
if err := cmd.Start(); err == nil || !strings.HasSuffix(err.Error(), "already started") {
|
||||
t.Fatalf("second call to Start returned a nil; want an 'already started' error")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue