From 20a4d1d3860aa7bca90e1b51501084d5c33ee4f1 Mon Sep 17 00:00:00 2001 From: Joachim Schmitz Date: Thu, 13 Sep 2012 08:55:08 +0200 Subject: [PATCH] poll: fix for systems that can't recv() on a non-socket * lib/poll.c: if recv returns ENOTSOCK, assume the descriptor is readable. In this case POLLHUP will not be supported. * doc/posix-functions/poll.texi: Document this. Copyright-paperwork-exempt: yes --- ChangeLog | 8 ++++++++ doc/posix-functions/poll.texi | 6 +++++- lib/poll.c | 4 ++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ab09b0e64..9764b116d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2012-09-13 Joachim Schmitz (tiny change) + Paolo Bonzini + + poll: fix for systems that can't recv() on a non-socket + * lib/poll.c: if recv returns ENOTSOCK, assume the descriptor + is readable. In this case POLLHUP will not be supported. + * doc/posix-functions/poll.texi: Document this. + 2012-09-13 Paolo Bonzini poll/select: document portability problems not fixed by Gnulib. diff --git a/doc/posix-functions/poll.texi b/doc/posix-functions/poll.texi index da619b99d..ec1bdda9c 100644 --- a/doc/posix-functions/poll.texi +++ b/doc/posix-functions/poll.texi @@ -10,7 +10,7 @@ Portability problems fixed by Gnulib: @itemize @item This function is missing on some platforms: -mingw, MSVC 9, BeOS. +mingw, MSVC 9, BeOS, HP NonStop. @item This function doesn't work on special files like @file{/dev/null} and ttys like @file{/dev/tty} on some platforms: @@ -27,4 +27,8 @@ created by the @code{socket} function, not on regular file descriptors. Under Windows, when passing a pipe, Gnulib's @code{poll} replacement might return 0 even before the timeout has passed. Programs using it with pipes can thus busy wait. + +@item +Under HP NonStop, file descriptors other than sockets do not support +POLLHUP; they will return a "readable" status instead. @end itemize diff --git a/lib/poll.c b/lib/poll.c index 5ad9d866b..b696dee0d 100644 --- a/lib/poll.c +++ b/lib/poll.c @@ -303,6 +303,10 @@ compute_revents (int fd, int sought, fd_set *rfds, fd_set *wfds, fd_set *efds) || socket_errno == ECONNABORTED || socket_errno == ENETRESET) happened |= POLLHUP; + /* some systems can't use recv() on non-socket, including HP NonStop */ + else if (socket_errno == ENOTSOCK) + happened |= (POLLIN | POLLRDNORM) & sought; + else happened |= POLLERR; } -- 2.11.0