Fix #14289 (#14304) [backport]

(cherry picked from commit 76f7e95814)
This commit is contained in:
slangmgh
2020-05-12 01:17:37 +08:00
committed by narimiran
parent 931a70b123
commit 6d5761d488

View File

@@ -997,10 +997,11 @@ when defined(windows) or defined(nimdoc):
proc addProcess*(pid: int, cb: Callback) =
## Registers callback ``cb`` to be called when process with process ID
## ``pid`` exited.
const NULL = Handle(0)
let p = getGlobalDispatcher()
let procFlags = SYNCHRONIZE
var hProcess = openProcess(procFlags, 0, pid.DWORD)
if hProcess == INVALID_HANDLE_VALUE:
if hProcess == NULL:
raiseOSError(osLastError())
var pcd = cast[PostCallbackDataPtr](allocShared0(sizeof(PostCallbackData)))