Poll / Kqueue on Mac OS X

Marc Lehmann schmorp at schmorp.de
Sun Dec 14 13:58:48 CET 2008

On Sun, Dec 14, 2008 at 05:07:56PM +1300, Space Ship Traveller <space.ship.traveller at gmail.com> wrote:
> I'm not sure what all the problems are regarding the kqueue API, however 
> I've encountered one problem with kqueue, which is that monitoring stdin 
> doesn't work at all.

stdin is just a file descriptor and works fine, as long as it is something
where os x doesn't barf (e.g. devices).

> I've actually resolved this problem with a rather roundabout hack.

It doesn't really solve the problem, as stdin could be a socket, and your
pipe isn't, so programs expecting stdin to be a socket (network servers)
would fail miserably.

> you are interested to support poll and kqueue on Mac OS X and other  

libev should already support poll and kqueue on os x just fine, by not using
it by default.

the only sane way known to use kqueue on the horribly broken os x platform
is to use it only for known-to-be-working file types (e.g. sockets), and
embed it into a select loop (for example).

> platforms which might be broken in this way, there is some example code 
> here which I have tested and used successfully:

unfortunately, it doesn't really fix anything :(

the solution documented in the libev manual works in all known cases,
however - maybe you should adopt it?

                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      pcg at goof.com
      -=====/_/_//_/\_,_/ /_/\_\

More information about the libev mailing list