cURL / Mailing Lists / curl-library / Single Mail


Re: Mac OS X and poll()

From: Jamie Lokier <>
Date: Fri, 9 Feb 2007 17:09:49 +0000

Daniel Stenberg wrote:
> >I've been using curl 7.16.1 modified to use poll() instead of select() on
> >Mac OS X for the last week. I haven't been able to trigger any problems
> >with it and all tests pass. My research indicates two things: poll doesn't
> >work when called on anything in /dev (actually a limitation of kqueue(),
> >which is used internally by poll), and the bug discussed at
> > seems to be fixed as of Mac
> >OS X 10.4.4 (Darwin 8.4.0).
> Nice. Can you come up with a way to detect a "good" Mac OS X version in
> which we should use poll() instead of select() ? To have the configure
> script do right automatically.

As far as I can tell, the bug discussed at
is that POLLHUP is set without setting POLLIN.
(The whole thread isn't too clear on what the bug is).

That's not unique to Mac OS X. According to the table at
some other systems set POLLHUP without POLLIN sometimes.

If that's right, it makes sense to either: (a) add an autoconf test
which creates a TCP socket pair, shutdown(SHUT_WR) one end, and polls
the other end to see if POLLIN is set or just POLLHUP; or (b) change
libcurl to treat POLLHUP as being equivalent to POLLIN.

The other Mac OS X poll() bug is that the emulation in 10.3 requires a
non-NULL poll table argument, but you're already testing for that. Of
course it would be easy enough to just use a non-NULL poll table
argument in libcurl, but no point as it's calling select() anyway.

Are there any other Mac OS X poll() bugs?

-- Jamie
Received on 2007-02-09