Hi,

we have a script that cron runs to run user scripts for us, log their results, make sure that only one of them is running, etc. Couple of days ago a user's script was hung for no apparent reason. So I tried to reproduce similar behavior and a buddy and I got it down to a pretty small subset of the functionality. I'm hoping maybe someone can shed a little light on what's going on here.

The stripped down version of the script-running script is this:

#!/usr/bin/perl -w use strict; use Proc::Spawn; my ($pid, $IN, $OUT, $ERROR) = spawn(\@ARGV); #fix by uncommenting this #while( <$ERROR>){}; # either of these hang my $junk = eof($OUT); #while (<$OUT>){};

And the stripped-down version of the user code is this:

#!/usr/bin/perl -w use strict; warn "x" x shift(@ARGV) . "\n";

so, save them puppies in "runner.pl" and "user.pl", chmod +x them, and issue this command:

[msouth@jinx GUI-APP bin]$ ./runner.pl ./user.pl 4095

then issue this command:

[msouth@jinx GUI-APP bin]$ ./runner.pl ./user.pl 4096

(then, if your system works like mine, you will want to do a control-c or something because it's just hanging there).

You can also test the commented assertion that unloading user.pl's stderr of its burden eliminates the problem. (Does on my system.)

(BTW, perl -v says:

This is perl, v5.6.1 built for i686-linux )

Just to make sure that I'm not confusing anyone, Proc::Spawn is producing IO::Handle objects there (lest anyone think that my subject implied I was doing this on vanilla filehandles).

I don't know diddly about IO. Anyone? (I would like to hear even if it's just that you can/can't reproduce it.)


In reply to 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.