watching for new files: libevent vs. libev

Marc Lehmann schmorp at
Thu Apr 4 21:45:25 CEST 2013

On Thu, Apr 04, 2013 at 01:04:35PM -0400, "Mikhail T." <mi+thun at> wrote:
> By adding EV_ET to the flags, I can watch a directory for changes --
> such as files being added or removed to it -- using libevent (at least,
> on FreeBSD). Sample program attached.

I don't quite understand why edge triggering would make this
possible. Certainly, edge triggering would have to be emulated for most
backends, and wouldn't result in any additional expressive power w.r.t.
directory watching.

> Does libev provide a similar functionality?

libev has ev_stat watchers which watch a path for changes in stat data,
within the limitations of portability (there is no portable way to check
for changes than to sample stat() data).

See the documentation for details.

> Some mailing list archives suggest, edge-triggered events aren't
> supported by libev (for portability?)

They are not implemented because they are rarely useful for performance,
but complicate things immensely for users of the library, and are not well
supported by most operating systems (that includes e.g. epoll).

> but those pages are from 2010. Have there been improvements since,
> perhaps?

It's not considered to be an improvement.

> Libevent did not have EV_ET until fairly recently too, but it is there
> now... Please, advise. Thank you!

I was under the impression that libevent did have edge triggering for,
like, forever, but maybe I confuse this with something else.

                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_    
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at
      -=====/_/_//_/\_,_/ /_/\_\

More information about the libev mailing list