Is it OK to poll() a device file descriptor

2013-06-18 Thread Elazar Leibovich
Try to open /dev/null, and then to poll the file descriptor. Neither in the man page nor in the standard I see anything preventing you to poll on /dev/null, yet, it does not work on Mac OS X. You get a POLLNVAL. Run the following: https://gist.github.com/elazarl/5805848 #include stdio.h

Re: Is it OK to poll() a device file descriptor

2013-06-18 Thread Oleg Goldshmidt
Elazar Leibovich elaz...@gmail.com writes: Try to open /dev/null, and then to poll the file descriptor. Neither in the man page nor in the standard I see anything preventing you to poll on /dev/null, yet, it does not work on Mac OS X. You get a POLLNVAL. From

Re: Is it OK to poll() a device file descriptor

2013-06-18 Thread Shachar Shemesh
On 18/06/13 17:43, Elazar Leibovich wrote: Try to open /dev/null, and then to poll the file descriptor. Neither in the man page nor in the standard I see anything preventing you to poll on /dev/null, yet, it does not work on Mac OS X. You get a POLLNVAL. Under Linux, whether you can poll

Re: Is it OK to poll() a device file descriptor

2013-06-18 Thread Elazar Leibovich
Damn I missed that. To my defense, this bug should be also mentioned in the POLLNVAL section. As it stands now, it looks like the only reason for POLLNVAL is a closed file descriptor. Sorry and thanks. On Tue, Jun 18, 2013 at 6:09 PM, Oleg Goldshmidt p...@goldshmidt.org wrote: Elazar

Re: Is it OK to poll() a device file descriptor

2013-06-18 Thread Elazar Leibovich
I'm using it as a fake always non-blocking file descriptor. My main libevent-like poll loop looks like: poll(fds) for fd in fds: if fd.revents | POLLIN: fd.read_callback() if fd.revents | POLLOUT: fd.write_callback() Now let's say I want a fake

Re: Is it OK to poll() a device file descriptor

2013-06-18 Thread Shachar Shemesh
On 18/06/13 22:16, Elazar Leibovich wrote: I'm using it as a fake always non-blocking file descriptor. My main libevent-like poll loop looks like: poll(fds) for fd in fds: if fd.revents | POLLIN: fd.read_callback() if fd.revents | POLLOUT: