I haven't looked at the code for Proc::Spawn, but from the symptoms you describe I would guess they are pipes; as I understand it, it is quite normal for a pipe to have a 4k buffer, and when the buffer is full the writer will block on any attempt to write more data to the pipe until the reader reads some out.

So in this case you have deadlock: the writer has written 4096 'x's to the stderr pipe, filling it, and is blocked trying to write the newline; the reader is sitting waiting for something on stdout, and there's nothing there (nor has it been closed, so there is no eof).

To avoid such deadlock you need to use nonblocking reads throughout, and be prepared to read from whichever handle has data ready, which you'd normally do with a 4-arg select loop.

You may also want to look at File::Tail which wraps up some of those details for you.

Hugo


In reply to Re: eof(FH) hanging when 4096 chars waiting on stderr (or something like that) by hv
in thread eof(FH) hanging when 4096 chars waiting on stderr (or something like that) 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.