watchexec/command-group

`stdlib::child::Windows::ChildImp::try_wait` shouldn't fail on timeout of GetQueuedCompletionStatus

bmc-msft opened this issue · 0 comments

Per the documentation on GetQueuedCompletionStatus:

The number of milliseconds that the caller is willing to wait for a completion packet to appear at the completion port. If a completion packet does not appear within the specified time, the function times out, returns FALSE, and sets *lpOverlapped to NULL.

As such, calling wait_imp(0) as shown here:

self.wait_imp(0)?;

Which calls GetQueuedCompletionStatus here:

res_bool(unsafe {
GetQueuedCompletionStatus(
self.handles.completion_port,
&mut code,
&mut key,
overlapped.as_mut_ptr(),
timeout,
)
})?;

A timeout will result in FALSE, which results in an Err.

This is contrary to normal behavior for try_wait. I would expect the try_wait to not fail on GetQueuedCompletionStatus timeout, but instead act like underlying impl of try_wait and return an Ok(None), or handle non-timeout errors specifically.