By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,698 Members | 1,535 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,698 IT Pros & Developers. It's quick & easy.

Output buffering problems during recursion

P: n/a
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
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Tim Mohler <ta******@nyc.rr.com> wrote:
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.

--
Steve
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.