How to disable EV_FORK_ENABLE when building lib?

Marc Lehmann schmorp at
Wed Feb 9 16:26:27 CET 2022

On Wed, Feb 09, 2022 at 09:55:11AM -0500, Olivier Langlois <olivier at> wrote:
> Sorry for the silly question...

It's actually not an obvious question :)

> I usually find the answer to that type of questions by doing .configure
> --help or reading a build.txt file or something like that.

That's likely because confiure is meant to built the standard version of
libev, and disabling fork watchers would be unexpected - e.g. if we had
tests for that watcher for testsuite, it would fail to test.

However, you shoulöd be able to do what you want simply by specifyingt the
right CFLAGS, e.g.:

   ./configure CFLAGS=-DEV_FORK_ENABLE=0

I haven't tested this, and you would normally need to also #define this
every time you #include ev.h (although it might work without in the case
of disabling fork watchers, it will not work with anything that changes
the data structure layout).

Since the resulting libev library is incompatible with a normal libev, you
would have to be careful not to install it anywhere where other programs
might find it, though.

If your gial is simply to have a non-standard libev for your project, it
would normally be easier to embed libev, and have your own wrapper files. For
example, rxvt-unicode has two files, a header called ev_cpp.h, which looks
similar to this:

   #define ECB_NO_THREADS 1

   #define EV_COMPAT3 0
   #define EV_USE_SELECT 1
   #define EV_USE_EPOLL 1
   #define EV_USE_KQUEUE 1
   #define EV_USE_PORT 1

   #include "ev.h"

And you would include this file whenever you normally would use ev.h.
Additionally, there is a ev_cpp.C file, which looks like this:

   #include "ev_cpp.h"
   #include "ev.c"

And this is the file that gets compiled into your program.

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

More information about the libev mailing list