Re: Event notice between processes, not threads?

2018-05-29 Thread Daniel Austin
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  wrote:

> On Sun, May 27, 2018 at 10:03:32PM -0700, Daniel Austin <
> daniel.r.aus...@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
>   --==---/ / _ \/ // /\ \/ /  schm...@schmorp.de
>   -=/_/_//_/\_,_/ /_/\_\
>
___
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/mailman/listinfo/libev

Re: Event notice between processes, not threads?

2018-05-29 Thread Marc Lehmann
On Sun, May 27, 2018 at 10:03:32PM -0700, Daniel Austin 
 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
  --==---/ / _ \/ // /\ \/ /  schm...@schmorp.de
  -=/_/_//_/\_,_/ /_/\_\

___
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/mailman/listinfo/libev