I'm not sure what's going on here exactly, but check this out from the fine documentation for IPC::Open3:

If you try to read from the child’s stdout writer and their stderr writer, you’ll have problems with blocking, which means you’ll want to use select() or the IO::Select, which means you’d best use sysread() instead of readline() for normal stuff.

Sounds right to me. Why not try it?

UPDATE: Oh, now I see it. It's the wait(). You're trying to let the process finish but it can't finish because it has filled it's STDOUT buffer and can't continue. It works with small numbers because the buffer doesn't fill. Remove that wait() and your code runs to completion.

UPDATE 2: For what it's worth, Expect is, in my experience, a better tool for this type of job. The documentation is a total mess but if you've ever used the TCL Expect it works the same way. Unlike IPC::Open3, it takes care of all the messy buffering and deadlocking problems. All you have to do is write the matching code.

-sam


In reply to Re: Script hangs when called via IPC::Open3 by samtregar
in thread Script hangs when called via IPC::Open3 by jeffa

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.