<div dir="ltr">Hi,<div>I'm try to use AnyEvent::Fork and here is my test code:</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>my $cv = AE::cv;</div></div><div><div>my $l = [];</div></div><div><div><br></div></div><div><div>AnyEvent::Fork</div></div><div><div>   ->new</div></div><div><div>   ->eval ('</div></div><div><div>        # compile a helper function for later use</div></div><div><div>        sub run {</div></div><div><div>            my $fh = shift;</div></div><div><div>            sleep 10;</div></div><div><div>        }</div></div><div><div>     ')</div></div><div><div>    ->run ("run", sub {</div></div><div><div>        my ($fh) = @_;</div></div><div><div>        my $n = sysread $fh, my $dummy, 1;   # doesn't block here</div></div><div><div>        print $!;</div></div><div><div>        print "$dummy, here\n";</div></div><div><div>        $cv->send;</div></div><div><div>         }</div></div><div><div>   );</div></div><div><div><br></div></div><div><div>my $stderr = $cv->recv;</div></div><div><br></div></blockquote>wish to use sysread to detect the child process exit, expect it will block until the child exit, but it  not, and directly return undef and $! is<div>     "Resource temporarily unavailable"</div><div><br></div><div>I also tried replace sysread with a AE io watcher:<br></div><div><br></div><div><div>        my $rw; $rw = AE::io $fh, 0, sub {</div><div>            print "parent here\n";</div><div>            print <$fh> . "\n";   # wierd, this line is required</div><div>           undef $rw;</div><div>           $cv->send;</div><div>        };</div><div>       $l->[0] = $rw;</div></div><div><div><br></div></div><div>this works, and print:</div><div>parent here</div><div><br></div><div>the wierd thing is, the line "print <$fh> . "\n";" must exist, otherwise, it'll blocked and never print anything.</div><div><br></div><div>can you figure out where's wrong in my code? </div><div><br></div><div><br></div><div>Regards,</div><div><br></div><div>tadegenban</div></div>