home *** CD-ROM | disk | FTP | other *** search
/ ftp.shrubbery.net / 2015-02-07.ftp.shrubbery.net.tar / ftp.shrubbery.net / pub / rancid / expect-hack2 < prev    next >
Text File  |  2005-06-20  |  950b  |  28 lines

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