in reply to Re: Re: Pipe, fork, exec and red-hot pokers.
in thread Pipe, fork, exec and red-hot pokers.

Interesting ... One thing which I would be looking to try at this point would be to incorporate autoflush on the created duplicate handles prior to the open3 invocation. eg.
my $STDOUT = IO::Handle->new; my $STDERR = IO::Handle->new; open($STDOUT, ">&STDOUT") || croak( 'Cannot duplicate STDOUT to file handle - ', $! ); open($STDERR, ">&STDERR") || croak( 'Cannot duplicate STDERR to file handle - ', $! ); $STDOUT->autoflush; $STDERR->autoflush;

If you still have no joy with this, you may have to incorporate a flush of the respective buffer prior to reading from it. eg. $STDOUT->flush. This may be necessary if some_application is actively buffering its output.

I'd be very interested to hear how you go with this and see if this resolves your problems with your specific application.

 

Replies are listed 'Best First'.
Re: Re: Re: Re: Pipe, fork, exec and red-hot pokers.
by hagus (Monk) on Apr 09, 2002 at 01:11 UTC
    No dice ... :( Same result.

    Here's my current theory. some_application believes that it's not running on a terminal (correctly), so it stops line buffering for some reason. It *does* flush its buffers on termination and on reaching the 4096 buffer limit (or whatever the precise number is).

    So perhaps another avenue to persue is fooling some_application into thinking that $STDOUT is in fact a tty?

    --
    Ash OS durbatulk, ash OS gimbatul,
    Ash OS thrakatulk, agh burzum-ishi krimpatul!
    Uzg-Microsoft-ishi amal fauthut burguuli.

      I've figured it out ... waitpid! *smacks own forehead*

      This is causing execution to halt until the child process invoked by open3 has terminated. As such, the latter lines which read from the $STDOUT and $STDERR are not being executed until after child has terminated and thus delays between output on these handles cannot be appreciated. You will need to remove the waitpid statement if you want to read from these output streams while some_application is executed.