Hi monks.
I have an in-house application that will not exit after running. The only way I've been able to have my script continue with the data it's been given is to open it up with IPC::Open2 (I believe this was recommended to me quite some time ago, after posting my specific problems).

The issue now is that no matter how much I sleep before issuing my "quit" command to the writer, I only get about half of what I want. I assume this has something to do w/ the way Open2 forks, but that's just a hunch.

An ugly example:
my $pid = open2(*HIS_OUT, *HIS_IN, "/my/application" ) || die $!; sleep 3; print HIS_IN "quit\n"; while ( <HIS_OUT> ) { chomp; &do_something_to($_); }
Even if I sleep for 15, I still only get about half of the full output. If I don't issue the quit command, I get all the output, but of course, my script is stuck, as it will never leave the HIS_OUT loop.

In reply to Question about IPC::Open2 by GaijinPunch

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.