AnyEvent and piped open
Laurent
laurent.aml at gmail.com
Sat Jul 16 00:42:40 CEST 2011
On Fri, Jul 15, 2011 at 5:20 PM, Marc Lehmann <schmorp at schmorp.de> wrote:
> On Fri, Jul 15, 2011 at 01:51:05PM -0400, Laurent <laurent.aml at gmail.com> wrote:
>> So wait/waitpid (and wrappers such as close() for piped open) should
>> not be relied upon with EV.
>
> 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.
>> AnyEvent doc is less clear on the subject. It suggests that some
>> implementations support to set the child handler after the child
>> exists, but don't mention the EV restriction (no event loop between
>> process creation and child event initialization).
Argh.... s/exists/exits/.
>
> There is no restriction, this is just common sense - you cannot expect to
> set a child watcher on a nonexistant process.
>
>> For example, I have not seen anything about it for the pure Perl
>> implementation (possibly because there is no such limitation for it?).
>
> If, with "limitation" you mean that the process still has to exist, then all
> event loops have this limitation.
>
> 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,
which would be the reason why one need to define the child watcher
before that happens.
Other event loops could have a different behavior, ie just reaping
children they have an child watcher on. In this case, unwatched
zombies will live across event loop runs until one reap them. In such
a case, the "limitation" would not exist (and my testcase would work).
-- Laurent
More information about the anyevent
mailing list