The likely problem is that you check HIS_ERR before anything is written there, then wait on output to HIS_OUT. Meanwhile he sends output to HIS_ERR and waits for input on HIS_IN. (It is theoretically possible that there are additional buffering problems.)

There are generally 3 ways to go. First you can look for a real API to use that will be more reliable. Secondly you can learn about select, sysread and syswrite. This will let you follow 2 handles at once, but you will need to handle stuff that Perl normally takes care of with buffering. The third is that you can use a module like Expect to abstract away some of those details.

I would first look for an API, then I'd look at Expect. I would not hand-roll a solution from unbuffered IO.


In reply to Re: IPC::open3 obfuscification by tilly
in thread IPC::open3 obfuscification by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.