io watcher: how to catch close(fd) after starting watcher

Jan-Philip Gehrcke jgehrcke at
Fri Nov 9 00:20:56 CET 2012

On 08.11.2012 22:12, Marc Lehmann wrote:

> There isn't any intended behaviour, anything goes. Effectively you run
> into undefined behaviour.

Okay, I understand that the application should not run into this 
situation, so further questions are just for my understanding.

>> "Some backends (e.g. kqueue, epoll) need to be told about closing a
>> file descriptor (either by calling close explicitly or by any other
>> means, such as dup). The reason is that you register interest in some
>> file descriptor, but when it goes away, the operating system will
>> silently drop this interest."
>> I call close explicitly (Python's os.close(fd) uses on POSIX
>> close(fd)), so am I not already following this advice?
> close does not tell epoll anything (and even if, epoll isn't libev) - what
> that sentence means is that close is not the only function that closes
> file descriptors.

I was mainly wondering about the documentation's "Some backends need to 
be told about closing a file descriptor". I inferred from that that 
there is a way to tell the backend that we've closed the descriptor. And 
from that I inferred that after telling the backend, libev detects and 
handles this situation (via stopping the watcher, throwing an error or 

Thanks for the insights,


More information about the libev mailing list