From f14119b561cfeefb93e8d773033caeea572dbe71 Mon Sep 17 00:00:00 2001 From: Colin Arnott Date: Thu, 16 Jul 2020 17:42:47 +0000 Subject: os: export errFinished as ErrProcessDone (*Process).Signal returns an error sentinel, previously errFinished, when (*Process).done or syscall.ESRCH. Callers would like the ability to test for this state, so the value has been exported as ErrProcessDone. Fixes #39444 Change-Id: I510e7647cc032af290180de5149f35ab7b09a526 Reviewed-on: https://go-review.googlesource.com/c/go/+/242998 Run-TryBot: Ian Lance Taylor Reviewed-by: Ian Lance Taylor Reviewed-by: Tobias Klauser Trust: Tobias Klauser --- src/os/exec_unix_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/os/exec_unix_test.go (limited to 'src/os/exec_unix_test.go') diff --git a/src/os/exec_unix_test.go b/src/os/exec_unix_test.go new file mode 100644 index 0000000000..d942cdb5e5 --- /dev/null +++ b/src/os/exec_unix_test.go @@ -0,0 +1,29 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris + +package os_test + +import ( + "internal/testenv" + . "os" + "testing" +) + +func TestErrProcessDone(t *testing.T) { + testenv.MustHaveGoBuild(t) + path, err := testenv.GoTool() + if err != nil { + t.Errorf("finding go tool: %v", err) + } + p, err := StartProcess(path, []string{"go"}, &ProcAttr{}) + if err != nil { + t.Errorf("starting test process: %v", err) + } + p.Wait() + if got := p.Signal(Kill); got != ErrProcessDone { + t.Errorf("got %v want %v", got, ErrProcessDone) + } +} -- cgit v1.3