--- exp_chan.c.FCS Thu Jun 3 20:31:46 2004 +++ exp_chan.c Fri Jun 4 00:05:03 2004 @@ -109,6 +109,7 @@ ExpState *esPtr = (ExpState *) instanceData; int bytesRead; /* How many bytes were actually * read from the input device? */ +struct pollfd fds[1]; *errorCodePtr = 0; @@ -118,6 +119,16 @@ * possible, if the channel is in blocking mode. If the channel is * nonblocking, the read will never block. */ +fds[0].fd = esPtr->fdin; +fds[0].events = POLLIN | POLLERR | POLLHUP | POLLNVAL; +bytesRead = poll(fds, 1, 0); +if (bytesRead <= 0) { + *errorCodePtr = EWOULDBLOCK; + return(-1); +} else if (fds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) { + *errorCodePtr = EBADF; + return(-1); +} bytesRead = read(esPtr->fdin, buf, (size_t) toRead); /*printf("ExpInputProc: read(%d,,) = %d\r\n",esPtr->fdin,bytesRead);*/