
Hi PHO,
On Fri, Mar 15, 2013 at 3:54 PM, PHO
I wrote a small program to test if a given stdin is supported by kqueue, poll and select: https://gist.github.com/phonohawk/5169980#file-kqueue-poll-select-cpp
MacOS X 10.5.8 is hopelessly broken. We can't use anything other than select(2) for tty and other devices:
https://gist.github.com/phonohawk/5169980#file-powerpc-apple-darwin9-8-0-txt
I just ran your program on OS X 10.8.2. It works fine with tty $ ./a.out Type of stdin: tty Checking if kqueue(2) works... Great. kevent(2) successfully handled your stdin. Checking if poll(2) works... Good. poll(2) successfully handled your stdin. Checking if select(2) works... OK. select(2) successfully handled your stdin. and fails with /dev/random, as you report: $ ./a.out < /dev/random Type of stdin: device Checking if kqueue(2) works... kevent(2) ifself succeeded but delivered us an EV_ERROR. This is how the old I/O manager was fooled because it wasn't (and the newer one still don't) check this situation: Invalid argument kevent(2) expectedly failed now. This time we didn't pass a non-NULL incoming event buffer. This is how the new I/O manager fails on this platform.: Invalid argument Checking if poll(2) works... poll(2) itself succeeded but delivered us a POLLNVAL event. It can't handle your stdin. Checking if select(2) works... OK. select(2) successfully handled your stdin. Note also that no implementations of kqueue
support monitoring writability of regular file writes, which also endangers the current use of kqueue-based I/O manager namely "threadWaitWrite".
Are you sure about this? Do you have any example program demonstrating this? I just took your kqueue-poll-select.cpp program and tested registering a file for a write event (i.e. changing EVFILT_READ to EVFILT_WRITE, POLLIN to POLLOUT, and use writefds rather than readfds) and it works fine on a file: $ ./a.out < foo Type of stdin: regular Checking if kqueue(2) works... Great. kevent(2) successfully handled your stdin. Checking if poll(2) works... Good. poll(2) successfully handled your stdin. Checking if select(2) works... OK. select(2) successfully handled your stdin. -Andi