|
|
|
@ -285,8 +285,7 @@ func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) {
|
|
|
|
|
}
|
|
|
|
|
return false, err
|
|
|
|
|
}
|
|
|
|
|
const STILL_ACTIVE = 259 // https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getexitcodeprocess
|
|
|
|
|
h, err := windows.OpenProcess(processQueryInformation, false, uint32(pid))
|
|
|
|
|
h, err := windows.OpenProcess(windows.SYNCHRONIZE, false, uint32(pid))
|
|
|
|
|
if err == windows.ERROR_ACCESS_DENIED {
|
|
|
|
|
return true, nil
|
|
|
|
|
}
|
|
|
|
@ -296,10 +295,9 @@ func PidExistsWithContext(ctx context.Context, pid int32) (bool, error) {
|
|
|
|
|
if err != nil {
|
|
|
|
|
return false, err
|
|
|
|
|
}
|
|
|
|
|
defer syscall.CloseHandle(syscall.Handle(h))
|
|
|
|
|
var exitCode uint32
|
|
|
|
|
err = windows.GetExitCodeProcess(h, &exitCode)
|
|
|
|
|
return exitCode == STILL_ACTIVE, err
|
|
|
|
|
defer windows.CloseHandle(h)
|
|
|
|
|
event, err := windows.WaitForSingleObject(h, 0)
|
|
|
|
|
return event == uint32(windows.WAIT_TIMEOUT), err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *Process) PpidWithContext(ctx context.Context) (int32, error) {
|
|
|
|
|