Output buffering problems during recursion

T

Tim Mohler

All -

I have a script that provides a web page interface to various system
utilities. Once the user has selected the utility and input various
parameters, it calls itself with a different method and input value,
for instance ping.

During the initial call, the output is not buffered, but on the second
call, the actually executes the utility, output is buffered until the
command completes.

I have $| set to 1 in both the initial user form routine and during
the utility routine.

I am using perl 5.8 and Apache 2.0.40. On the old box, with perl 5.6
and Apache 1.3, it works perfectly. Also, on the new box (with the new
versions) a simple perl script called from the command line runs
utilities like ping perfectly with no buffering.

Anyone have any ideas?

Thanks
Tim Mohler
 
S

Steve Grazzini

Tim Mohler said:
I have a script that provides a web page interface to various system
utilities. Once the user has selected the utility and input various
parameters, it calls itself with a different method and input value,
for instance ping.

During the initial call, the output is not buffered, but on the second
call, the actually executes the utility, output is buffered until the
command completes.

I have $| set to 1 in both the initial user form routine and during
the utility routine.

$| doesn't actually have anything to do with buffering. It tells
perl to flush the selected filehandle's stdio buffers after each
write.

When you fork and exec an external program (like ping), the child
process will set up its *own* stdio buffers without knowing or caring
anything about $|. The only thing it cares about, usually, is whether
standard output is connected to a terminal -- if you hook it up to a
pty (with e.g. Expect or IO::pty) you'll probably get line-buffered
output.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top