closing fd while in loop

Nicolas Van Eenaeme nicolas at
Sun Mar 2 20:27:53 CET 2014

Hi Marc,

Do we need to stop the watchers before closing the fd, or the way around?
Since in the documentation it says for EVBACKEND_EPOLL:

"Best performance from this backend is achieved by not unregistering all
watchers for a file descriptor until it has been closed, if possible, i.e.
keep at least one watcher active per fd at all times. Stopping and starting
a watcher (without re-setting it) also usually doesn't cause extra
overhead. A fork can both result in spurious notifications as well as in
libev having to destroy and recreate the epoll object, which can take
considerable time and thus should be avoided."

Or doesn't it make that much difference?

Thanks a lot!


2014-03-01 21:38 GMT+01:00 Marc Lehmann <schmorp at>:

> On Sat, Mar 01, 2014 at 07:04:40PM +0330, Jafar habibi livar <
> iceberg.90427 at> wrote:
> > if i close fd while the watcher is registered in a loop, will libev stop
> > the watcher or should I do it manually?
> You need to stop all watchers for the fd before closing the fd.
> --
>                 The choice of a       Deliantra, the free code+content
>       -----==-     _GNU_    
>       ----==-- _       generation
>       ---==---(_)__  __ ____  __      Marc Lehmann
>       --==---/ / _ \/ // /\ \/ /      schmorp at
>       -=====/_/_//_/\_,_/ /_/\_\
> _______________________________________________
> libev mailing list
> libev at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the libev mailing list