<div dir="ltr">Thank you for your explain. I'm rarely work with I/O stuff<div><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span style="font-size:14px">Also: maybe that module isn't actually what you want - there are higher</span><br style="font-size:14px"><span style="font-size:14px">level modules that make it easier to communicate with AnyEvent::Fork</span><br style="font-size:14px"><span style="font-size:14px">subprocesses, namely AnyEvent::Fork::RPC and AnyEvent::Fork::Pool - they</span><br style="font-size:14px"><span style="font-size:14px">deal with this low-level event handling stuff, and thus make it much more</span><br style="font-size:14px"><span style="font-size:14px">convenient.</span><br></blockquote><div><br><div>I'm using AnyEvent::Fork::Pool now, it seems worked for me.</div><div><br></div><div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span style="font-size:14px">Makes perfect sense, the filehandle is non-blocking and when there isn't any</span><br style="font-size:14px"><span style="font-size:14px">data, you get "Resource temporarily unavailable".</span></blockquote><div> </div><div>Actually I found a samilar question here, and there is an answer from you<br><div><a href="http://stackoverflow.com/questions/27153465/anyeventfork-how-to-wait-for-child/27219603#27219603">http://stackoverflow.com/questions/27153465/anyeventfork-how-to-wait-for-child/27219603#27219603</a><br></div></div><div><br></div><div>which says :</div><div>"<span style="color:rgb(34,36,38);font-family:Arial,'Helvetica Neue',Helvetica,sans-serif;font-size:15px;line-height:19.5px">The sysread will try to read from the child. If the child never sends anything, this will block the parent until the child exits, as in that moment, the child will close it's end of the pipe and sysread gets an EOF.</span>"</div><div>so my question is why my sysread (or <span style="font-size:14px"> maybe </span><span style="font-size:14px">filehandle</span><span style="font-size:14px"> </span>) will not block the parent as you said?</div></div><div><br></div><div>Regards</div><div class="gmail_extra"><br><div class="gmail_quote">2016-03-27 23:46 GMT+08:00 Marc Lehmann <span dir="ltr"><<a href="mailto:schmorp@schmorp.de" target="_blank">schmorp@schmorp.de</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">On Fri, Mar 25, 2016 at 12:28:36AM +0800, Genban Tade <<a href="mailto:tadegenban@gmail.com">tadegenban@gmail.com</a>> wrote:<br>
> wish to use sysread to detect the child process exit, expect it will block<br>
> until the child exit, but it  not, and directly return undef and $! is<br>
>      "Resource temporarily unavailable"<br>
<br>
</span>Makes perfect sense, the filehandle is non-blocking and when there isn't any<br>
data, you get "Resource temporarily unavailable".<br>
<span class=""><br>
> I also tried replace sysread with a AE io watcher:<br>
><br>
</span><span class="">> this works, and print:<br>
> parent here<br>
<br>
</span>It works, because you read data when there actually is data, not before.<br>
<span class=""><br>
> can you figure out where's wrong in my code?<br>
<br>
</span>I suspect that you need to polish up your skills with I/O a bit - have<br>
you had a look at AnyEvent::Intro, to get into the basics of event-based<br>
programming?<br>
<br>
Also: maybe that module isn't actually what you want - there are higher<br>
level modules that make it easier to communicate with AnyEvent::Fork<br>
subprocesses, namely AnyEvent::Fork::RPC and AnyEvent::Fork::Pool - they<br>
deal with this low-level event handling stuff, and thus make it much more<br>
convenient.<br>
<span class=""><font color="#888888"><br>
--<br>
                The choice of a       Deliantra, the free code+content MORPG<br>
      -----==-     _GNU_              <a href="http://www.deliantra.net" rel="noreferrer" target="_blank">http://www.deliantra.net</a><br>
      ----==-- _       generation<br>
      ---==---(_)__  __ ____  __      Marc Lehmann<br>
      --==---/ / _ \/ // /\ \/ /      <a href="mailto:schmorp@schmorp.de">schmorp@schmorp.de</a><br>
      -=====/_/_//_/\_,_/ /_/\_\<br>
</font></span></blockquote></div><br></div></div></div></div>