Fix a bug with starting of asynchronous processes (#18464)

The asynchronous process completion handler callback should be called
only once. This is achieved by passing `WT_EXECUTEONLYONCE` flag to the
`registerWaitForSingleObject` Windows API procedure.

Related to cheatfate/asynctools#35
This commit is contained in:
Ivan Bobev 2021-07-09 03:26:49 +03:00 • committed by GitHub
commit 86f5a56fcd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1022,7 +1022,7 @@ when defined(windows) or defined(nimdoc):
raiseOSError(osLastError()) raiseOSError(osLastError())
var pcd = cast[PostCallbackDataPtr](allocShared0(sizeof(PostCallbackData))) var pcd = cast[PostCallbackDataPtr](allocShared0(sizeof(PostCallbackData)))
var flags = WT_EXECUTEINWAITTHREAD.DWORD var flags = WT_EXECUTEINWAITTHREAD.DWORD or WT_EXECUTEONLYONCE.DWORD
proc proccb(fd: AsyncFD, bytesCount: DWORD, errcode: OSErrorCode) = proc proccb(fd: AsyncFD, bytesCount: DWORD, errcode: OSErrorCode) =
closeWaitable(hProcess) closeWaitable(hProcess)