2 * (c) The GRASP/AQUA Project, Glasgow University, 1994-2002
4 * hWaitForInput Runtime Support
7 /* select and supporting types is not Posix */
8 /* #include "PosixSource.h" */
12 * inputReady(fd) checks to see whether input is available on the file
13 * descriptor 'fd'. Input meaning 'can I safely read at least a
14 * *character* from this file object without blocking?'
17 inputReady(int fd, int msecs, int isSock)
20 #ifndef mingw32_TARGET_OS
32 /* select() will consider the descriptor set in the range of 0 to
36 tv.tv_sec = msecs / 1000;
37 tv.tv_usec = (msecs % 1000) * 1000;
39 while ((ready = select(maxfd, &rfd, NULL, NULL, &tv)) < 0 ) {
40 if (errno != EINTR ) {
45 /* 1 => Input ready, 0 => not ready, -1 => error */
48 #ifdef mingw32_TARGET_OS
51 HANDLE hFile = (HANDLE)_get_osfhandle(fd);
53 rc = WaitForMultipleObjects( 1,
58 /* 1 => Input ready, 0 => not ready, -1 => error */
60 case WAIT_TIMEOUT: return 0;
61 case WAIT_OBJECT_0: return 1;