Event notice between processes, not threads?

Marc Lehmann schmorp at schmorp.de
Tue May 29 16:28:22 CEST 2018


On Sun, May 27, 2018 at 10:03:32PM -0700, Daniel Austin <daniel.r.austin at gmail.com> wrote:
> Hi.  What is the proper mechanism to trigger an event in a separate
> process, not a separate thread, assuming a modern Linux kernel?
> 
> 1) Use ev_io on an eventfd file descriptor.  Use normal eventfd file

That, or a pipe, are the most reasonable options. Which one is faster
depends very much on the application.

> "register" with the triggering process, but they do need to get access to
> the file description number somehow (e.g. shared memory or other means).

The fd number is useless in another process - you cna pass file
descriptions to other pĆ¼rocesses with file descriptor passing via a unix
domain socket, though, or inheriting using fork for example.

> 2) Use ev_async.  I think the proper usage here would be to put the

ev_async cannot be used for this purpose.

> 3) Something else?

Use inotify to watch for file changes. There are some other mechanisms,
but for general event handling, you want a pipe or something like eventfd.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\



More information about the libev mailing list