- int maxfd, ready;
- fd_set rfd;
- struct timeval tv;
-
- FD_ZERO(&rfd);
- FD_SET(fd, &rfd);
-
- /* select() will consider the descriptor set in the range of 0 to
- * (maxfd-1)
- */
- maxfd = fd + 1;
- tv.tv_sec = msecs / 1000;
- tv.tv_usec = msecs % 1000;
-
- while ((ready = select(maxfd, &rfd, NULL, NULL, &tv)) < 0 ) {
- if (errno != EINTR ) {
- return -1;
- }
- }
-
- /* 1 => Input ready, 0 => not ready, -1 => error */
- return (ready);
+ int maxfd, ready;
+ fd_set rfd;
+ struct timeval tv;
+
+ FD_ZERO(&rfd);
+ FD_SET(fd, &rfd);
+
+ /* select() will consider the descriptor set in the range of 0 to
+ * (maxfd-1)
+ */
+ maxfd = fd + 1;
+ tv.tv_sec = msecs / 1000;
+ tv.tv_usec = msecs % 1000;
+
+ while ((ready = select(maxfd, &rfd, NULL, NULL, &tv)) < 0 ) {
+ if (errno != EINTR ) {
+ return -1;
+ }
+ }
+
+ /* 1 => Input ready, 0 => not ready, -1 => error */
+ return (ready);
+ }
- } else {
- DWORD rc;
- HANDLE hFile = (HANDLE)_get_osfhandle(fd);
-
- rc = MsgWaitForMultipleObjects( 1,
- &hFile,
- FALSE, /* wait all */
- msecs, /*millisecs*/
- QS_ALLEVENTS);
-
- /* 1 => Input ready, 0 => not ready, -1 => error */
- switch (rc) {
- case WAIT_TIMEOUT: return 0;
- case WAIT_OBJECT_0: return 1;
- default: return -1;
- }
+ else {
+ DWORD rc;
+ HANDLE hFile = (HANDLE)_get_osfhandle(fd);
+
+ rc = MsgWaitForMultipleObjects( 1,
+ &hFile,
+ FALSE, /* wait all */
+ msecs, /*millisecs*/
+ QS_ALLEVENTS);
+
+ /* 1 => Input ready, 0 => not ready, -1 => error */
+ switch (rc) {
+ case WAIT_TIMEOUT: return 0;
+ case WAIT_OBJECT_0: return 1;
+ default: return -1;
+ }