mkueper has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,
I know there are many posts around this topic, but none seems to help me with my problem, which is:
When I fill the child program's output to the parents stdout, (for example by this command:
my $pid = open3(\*STDIN, ">&STDOUT", \*STDERR, "streamtestinner.pl");
i only get the whole output, when the childprocess has completely finished. Thats not what i want. I want the console to reflect each print statement of the childprocess as soon as it is executed. (Seems like the stream isn't flushed or something like that) On Unix this works as it should, but the same code on windows behaves differently. Can anybody tell me if there is a way to get the desired result on windows too?
kind regards
Michael

Replies are listed 'Best First'.
Re: child process stream capturing and Windows
by cdarke (Prior) on Jun 16, 2009 at 10:08 UTC
    Seems like the stream isn't flushed or something like that

    STDERR should not be buffered, but you can mark STDOUT as unbuffered with local $! = 1;
      a already used the statement $| = 1 before the open3 command
        Have you done this in the child process as well, not just before you call the child in the parent process? I'm not too experienced in Perl on Windows, as I've mostly worked on Unix/Linux/OS X systems, but I believe that certain systems expect certain default behaviors. I don't know that the value for $| is inherited by the child; it might be set to the default of 'unflushed'.

        --
        tbone1, YAPS (Yet Another Perl Schlub)
        And remember, if he succeeds, so what.
        - Chick McGee