AnyEvent::Fork failed with sysread filehadle

Marc Lehmann schmorp at schmorp.de
Sun Mar 27 17:46:42 CEST 2016


On Fri, Mar 25, 2016 at 12:28:36AM +0800, Genban Tade <tadegenban at gmail.com> wrote:
> 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
>      "Resource temporarily unavailable"

Makes perfect sense, the filehandle is non-blocking and when there isn't any
data, you get "Resource temporarily unavailable".

> I also tried replace sysread with a AE io watcher:
> 
> this works, and print:
> parent here

It works, because you read data when there actually is data, not before.

> can you figure out where's wrong in my code?

I suspect that you need to polish up your skills with I/O a bit - have
you had a look at AnyEvent::Intro, to get into the basics of event-based
programming?

Also: maybe that module isn't actually what you want - there are higher
level modules that make it easier to communicate with AnyEvent::Fork
subprocesses, namely AnyEvent::Fork::RPC and AnyEvent::Fork::Pool - they
deal with this low-level event handling stuff, and thus make it much more
convenient.

-- 
                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