Output buffering problems during recursion

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tim Mohler

    Output buffering problems during recursion

    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
  • Steve Grazzini

    #2
    Re: Output buffering problems during recursion

    Tim Mohler <tamohler@nyc.r r.com> wrote:[color=blue]
    > 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.[/color]

    $| 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

    Comment

    Working...