Event notice between processes, not threads?

Daniel Austin daniel.r.austin at gmail.com
Tue May 29 18:07:26 CEST 2018


Hi, Marc.  Thank you for responding.  I did a little investigation on your
comment about fds being useless to other processes and did not know they
were process-unique.  Thanks for stopping me early. Your suggestion of a
pipe looks like it will be the fastest (to implement) approach.  Would I
simply have each watcher process ev_io watch the fifo for readable event,
the writer process puts a byte into the fifo, all the watcher processes get
the readable event and wake up and non-block read to empty the pipe (one
succeeds), do their respective tasks, and then repeat?  Thanks very much.

On Tue, May 29, 2018 at 7:28 AM, Marc Lehmann <schmorp at schmorp.de> wrote:

> 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
>       -=====/_/_//_/\_,_/ /_/\_\
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20180529/f62e88e8/attachment.html>


More information about the libev mailing list