AnyEvent and piped open
Marc Lehmann
schmorp at schmorp.de
Sat Jul 16 01:59:37 CEST 2011
On Fri, Jul 15, 2011 at 06:42:40PM -0400, Laurent <laurent.aml at gmail.com> wrote:
> > Neither wait nor waitpid changes function, actually.
>
> I meant, you cannot rely upon waitpid to reap your children, as there
> is a chance they already got reaped by EV.
Sure you can, it's absolutely deterministic. As long as you don't let EV
reap the children, you can still do it yourself. This is, for example, why
popen/pclose etc. in library functions isn't affected.
> > This is not, of course, a limitation - as soon as the process no longer
> > exists, it simply makes no sense to add a child watcher for it, because the
> > very pid that identifies the process could have been reused.
>
> Of course... I assume the child still exist, as a zombie, as long as
> it has not been reaped.
> I think EV reaps all zombie children any time the event loop runs,
Yes, thats what the event loop is supposed to do.
> Other event loops could have a different behavior, ie just reaping
> children they have an child watcher on.
I disagree - you are using the word "just" far too lightly. With EV, it's an
option, but if you use it, then you indeed need to use it for all the child
processes that you run in an event-based way.
The alternative you propose is polling for child process completion, which
is not really an option for an event library.
> In this case, unwatched zombies will live across event loop runs until
> one reap them. In such oa case, the "limitation" would not exist (and my
> testcase would work).
The limitation is only a limitation if you want to rely on non-event-based
methods (such as polling). EV allows you to do that, unless you mix
event-based reaping and non-event-based reaping isn't doable (on POSIX).
So, again, this really isn't a limitation (not even a "limitation") in EV,
but a logical consequence of using events. Note that traditional use of
popen/pclose works just fine even when EV reaps children.
--
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 anyevent
mailing list