From 785e379e67147adae44e183c95fff5ce1bb5a46d Mon Sep 17 00:00:00 2001 From: sunshineplan Date: Sun, 5 Sep 2021 11:09:45 +0800 Subject: [PATCH] v3/process (Win): fix Kill() DuplicateHandle error --- v3/process/process_windows.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/v3/process/process_windows.go b/v3/process/process_windows.go index 52c73d95..6183c0c6 100644 --- a/v3/process/process_windows.go +++ b/v3/process/process_windows.go @@ -650,7 +650,10 @@ func (p *Process) TerminateWithContext(ctx context.Context) error { } func (p *Process) KillWithContext(ctx context.Context) error { - process := os.Process{Pid: int(p.Pid)} + process, err := os.FindProcess(int(p.Pid)) + if err != nil { + return err + } return process.Kill() }