diff options
| author | Constantin Konstantinidis <constantinkonstantinidis@gmail.com> | 2021-11-28 15:19:15 +0100 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2022-04-03 21:26:39 +0000 |
| commit | 345184496ce358e663b0150f679d5e5cf1337b41 (patch) | |
| tree | 3db1a5d140dc978e0dc54356b26acef93f3a9966 /src/os/exec/exec_windows_test.go | |
| parent | 85b5f86584686677c554b2538a7edee96d684aea (diff) | |
| download | go-345184496ce358e663b0150f679d5e5cf1337b41.tar.xz | |
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 <pnyb@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/os/exec/exec_windows_test.go')
| -rw-r--r-- | src/os/exec/exec_windows_test.go | 18 |
1 files changed, 18 insertions, 0 deletions
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) + } +} |
