1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-05-01 13:48:52 +08:00

v3/process (Win): fix Kill() DuplicateHandle error

This commit is contained in:
sunshineplan 2021-09-05 11:09:45 +08:00
parent f8cc3bd072
commit 785e379e67

View File

@ -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()
}