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>
Johannes Sixt committed
Sep 23, 2008 at 08:52 UTC
d317851a7fd07f28890e6dc9bc2269da37c4122e
1 file changed
+6
-1
compat/mingw.c
+6
-1
@@ -263,8 +263,13 @@ int poll(struct pollfd *ufds, unsigned int nfds, int timeout)
263
{
264
int i, pending;
265
266
- if (timeout != -1)
266
+ if (timeout >= 0) {
267
+ if (nfds == 0) {
268
+ Sleep(timeout);
269
+ return 0;
270
+ }
271
return errno = EINVAL, error("poll timeout not supported");
272
+ }
273
274
/* When there is only one fd to wait for, then we pretend that
275
* input is available and let the actual wait happen when the