Hi,
When I tried a tiny program which uses gnulib's poll(2) emulation on
MacOS X 10.4, I found a bug. gnulib's poll(2) uses recv(2) with
MSG_PEEK to support POLLHUP. However, recv(2) is only applicable to a
socket, not to a file descriptor.
Though I don't know how to fix it, I think it can be by-passed if
(pfd[i].events & POLLHUP) == 0? Here is the patch
Index: poll.c
===================================================================
RCS file: /sources/gnulib/gnulib/lib/poll.c,v
retrieving revision 1.4
diff -u -r1.4 poll.c
--- poll.c 19 Sep 2005 17:28:14 -0000 1.4
+++ poll.c 11 Aug 2006 07:32:03 -0000
@@ -155,7 +155,8 @@
{
/* support for POLLHUP. An hung up descriptor does not
increase the return value! */
- if (recv (pfd[i].fd, data, 64, MSG_PEEK) == -1)
+ if (pfd[i].events & POLLHUP &&
+ recv (pfd[i].fd, data, 64, MSG_PEEK) == -1)
{
if (errno == ESHUTDOWN || errno == ECONNRESET
|| errno == ECONNABORTED || errno == ENETRESET)
Regards,
--
Daiki Ueno