From 345184496ce358e663b0150f679d5e5cf1337b41 Mon Sep 17 00:00:00 2001 From: Constantin Konstantinidis Date: Sun, 28 Nov 2021 15:19:15 +0100 Subject: os: add handling of os.Interrupt for windows Add GenerateConsoleCtrlEvent call to internal syscall package. Define ErrProcessDone while reviewing handling of os.Signal(). Update test to run for windows using the added call. Fixes #42311 Fixes #46354 Change-Id: I460955efc76c4febe04b612ac9a0670e62ba5ff3 Reviewed-on: https://go-review.googlesource.com/c/go/+/367495 Trust: Patrik Nyblom Run-TryBot: Ian Lance Taylor TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor --- src/os/exec/exec_windows_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/os/exec/exec_windows_test.go') diff --git a/src/os/exec/exec_windows_test.go b/src/os/exec/exec_windows_test.go index 8e31e47190..503867f9c8 100644 --- a/src/os/exec/exec_windows_test.go +++ b/src/os/exec/exec_windows_test.go @@ -7,6 +7,7 @@ package exec_test import ( + "internal/testenv" "io" "os" "os/exec" @@ -54,3 +55,20 @@ func TestNoInheritHandles(t *testing.T) { t.Fatalf("got exit code %d; want 88", exitError.ExitCode()) } } + +func TestErrProcessDone(t *testing.T) { + testenv.MustHaveGoBuild(t) + // On Windows, ProcAttr cannot be empty + p, err := os.StartProcess(testenv.GoToolPath(t), []string{""}, + &os.ProcAttr{Dir: "", Env: nil, Files: []*os.File{os.Stdin, os.Stdout, os.Stderr}, Sys: nil}) + if err != nil { + t.Errorf("starting test process: %v", err) + } + _, err = p.Wait() + if err != nil { + t.Errorf("Wait: %v", err) + } + if got := p.Signal(os.Kill); got != os.ErrProcessDone { + t.Fatalf("got %v want %v", got, os.ErrProcessDone) + } +} -- cgit v1.3