[Chicago-talk] Broken Pipe

Steven Lembark lembark at wrkhors.com
Mon Dec 12 16:46:10 PST 2005

-- "Young, Darren" <Darren.Young at ChicagoGSB.edu>

> Have a script that does an open() for read on a pipe. The particular
> binary can take a while to run (1-2 hours) and causes the Perl open() to
> eventually timeout and spew back 'broken pipe'. Can I do something as
> simple as:
> To get around this? Or, should I be thinking about a different IPC open
> mechanism (open2, open3, etc)?

You can try open3, but in general you should be able to
get by without it.
>     if ( open(STORED, "$cmd |") ) {

A blocking read should sit there forever if necessary. The
problem is that $cmd isn't putting out any data and is then
closing its stdout.

You can try:

    open my $fh, "$cmd > /var/tmp/thingy.log |" ...

and tail -f /var/tmp/thingy.log to -- hopefully -- find
out why the command is exiting without sending you any

You can also try running the command from the command
line into a named pipe and reading from the named one 
into perl (just a regular open my $fh, "< $pipe"). That
makes it easier to watch the writing job and see if it
spews out any errors:

    mknod /tmp/named_pipe p;

    /path/to/cmd --blah 2>&1 > /tmp/named_pipe | tee /tmp/error.log;

will show you the stderr output from the command and tee 
it to a log file for you (not the order of redirections).

Steven Lembark                                       85-09 90th Street
Workhorse Computing                                Woodhaven, NY 11421
lembark at wrkhors.com                                     1 888 359 3508

More information about the Chicago-talk mailing list