Skip to content

Commit d317851

Browse files
Johannes Sixtspearce
authored andcommitted
compat/mingw: Support a timeout in the poll emulation if no fds are given
Our poll() emulation did not support the timeout argument. With this patch we support it for the simple case where poll() does not need to wait on file descriptors as well because this case amounts to a mere Sleep(). This is needed if the user sets help.autocorrect is set to a positive value. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
1 parent 07ad5a1 commit d317851

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

compat/mingw.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,13 @@ int poll(struct pollfd *ufds, unsigned int nfds, int timeout)
263263
{
264264
int i, pending;
265265

266-
if (timeout != -1)
266+
if (timeout >= 0) {
267+
if (nfds == 0) {
268+
Sleep(timeout);
269+
return 0;
270+
}
267271
return errno = EINVAL, error("poll timeout not supported");
272+
}
268273

269274
/* When there is only one fd to wait for, then we pretend that
270275
* input is available and let the actual wait happen when the

0 commit comments

Comments
 (0)