I thought about suggesting select to turn off buffering, but didn't recommend that directly because it is less reliable.

What select would do is affect how you are buffering your communication to the other process. But you cannot with select guarantee that it won't buffer the input coming from you, in which case you are still SOL. But when you close the handle, your contents get flushed and it will know from the eof that there is no more to buffer.

Incidentally this is the basic danger with open2 and open3. You have to be very careful that your assumptions and the assumptions of the other program do not conflict in any way. For instance the above pattern (send, close, then read the response) works fine for small amounts of data. But if you try to send more than a page or 2 at once, it may decide to send you a response to the first bit before getting more from you. But you are still trying to send information. When this happens to you at a party, it is only mildly annoying. Humans being multi-tasking, one or the other usually spots the problem and the issue is resolved. But programs are willing to block on communication over this kind of boneheaded mistake for as long as it takes...


In reply to Re (tilly) 5: need help with open2, please! by tilly
in thread need help with open2, please! by blueflashlight

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.