AnyEvent and piped open

Laurent laurent.aml at gmail.com
Fri Jul 15 19:51:05 CEST 2011


Marc,

On Fri, Jul 15, 2011 at 2:49 AM, Marc Lehmann <schmorp at schmorp.de> wrote:
> On Thu, Jul 14, 2011 at 12:09:03PM -0400, Laurent <laurent.aml at gmail.com> wrote:
>> I am using AnyEvent/EV and try to catch the process termination of a piped open.
>
> Your program is buggy - you poll for new events ($cv->recv) _before_
> installing a child watcher. if your program exists before (very likely)

(and definitely intended in the testcase)

> then the child simply doesn't exist anymore.

Reading again the EV doc, this gets clear...
If I understand correctly, just running the event loop processes the
child termination.
I missed that part.

So wait/waitpid (and wrappers such as close() for piped open) should
not be relied upon with 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).
For example, I have not seen anything about it for the pure Perl
implementation (possibly because there is no such limitation for it?).


Thanks for your help.

-- Laurent



More information about the anyevent mailing list