2 * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
4 * $Id: inputReady.c,v 1.4 2001/12/21 15:07:26 simonmar Exp $
6 * hReady Runtime Support
9 /* select and supporting types is not Posix */
10 /* #include "PosixSource.h" */
14 * inputReady(fd) checks to see whether input is available on the file
15 * descriptor 'fd'. Input meaning 'can I safely read at least a
16 * *character* from this file object without blocking?'
19 inputReady(int fd, int msecs, int isSock)
22 #ifndef mingw32_TARGET_OS
34 /* select() will consider the descriptor set in the range of 0 to
38 tv.tv_sec = msecs / 1000;
39 tv.tv_usec = msecs % 1000;
41 while ((ready = select(maxfd, &rfd, NULL, NULL, &tv)) < 0 ) {
42 if (errno != EINTR ) {
47 /* 1 => Input ready, 0 => not ready, -1 => error */
49 #ifdef mingw32_TARGET_OS
52 HANDLE hFile = (HANDLE)_get_osfhandle(fd);
54 rc = MsgWaitForMultipleObjects( 1,
60 /* 1 => Input ready, 0 => not ready, -1 => error */
62 case WAIT_TIMEOUT: return 0;
63 case WAIT_OBJECT_0: return 1;