commit da70784bd2048f7f1a8934711e5e24f975d68b0b Author: Cedric Cellier Date: Tue Jun 21 16:30:45 2011 +0200 Fix fport_input_waiting when fd > SELECT_SET_SIZE (cherry-picked from 1-8-8) By allowing this function to use poll instead of select. diff --git a/libguile/fports.c b/libguile/fports.c index 0b84d44..f19d291 100644 --- a/libguile/fports.c +++ b/libguile/fports.c @@ -49,7 +49,9 @@ #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE #include #endif - +#ifdef HAVE_POLL_H +#include +#endif #include #include @@ -585,7 +587,14 @@ scm_fdes_to_port (int fdes, char *mode, SCM name) static int fport_input_waiting (SCM port) { -#ifdef HAVE_SELECT +#ifdef HAVE_POLL + int fdes = SCM_FSTREAM (port)->fdes; + struct pollfd pollfd = { fdes, POLLIN, 0 }; + if (poll(&pollfd, 1, 0) < 0) + scm_syserror ("fport_input_waiting"); + return pollfd.revents & POLLIN ? 1 : 0; + +#elif defined(HAVE_SELECT) int fdes = SCM_FSTREAM (port)->fdes; struct timeval timeout; SELECT_TYPE read_set;