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

Greetings, esteemed monks!

So I have been tilting at the windmill of handling STDOUT and STDERR of a child
synchronously, yet separately. I work in a Linux environment (RedHat 3 and 4 and perl 5.8.5).
I've resigned myself to getting halfway results with
sporadic attempts at refining my technique. I won't repeat myself here, but this node:

Re: Synchronizing STDERR and STDOUT

explains the current status of my efforts.

Here's an example of some output from the example child program:

<snip> <span id='stderr'>1</span> 2 <span id='stderr'>3</span> 4 <span id='stderr'>5</span> 6 8 10 12 14 16 18 <span id='stderr'>7 9 11 13 15 17 19 21 23 25 27 29 31 33 35</span> 20 <snip> 58 <span id='stderr'>37 39 <snip> 73</span> 60 62 <you get the picture>
As you can see in the code, autoflushing is turned on (in both child and parent) and the child should think it's connected to a tty.
However, the output is still buffered in chunks larger than one line.

Upon reading the whole thread that the above node is in, I found out about PerlIO and enabled logging for a run of the program.

I glanced through perlio.log and I found the following line:

/opt/perl/lib/site_perl/5.8.5/IPC/Run.pm:2613 Cannot flush f=0x805defc

here is line 2613 in my version of Run.pm:

open $s1, ">&=$self->{SYNC_WRITER_FD}" or croak "$! setting filehandle to fd SYNC_WRITER_FD" ;
I am curious about where the "Cannot flush" message originated and why. Any ideas?

Terrence

_________________________________________________________________________________

I like computer programming because it's like Legos for the mind.

Replies are listed 'Best First'.
Re: Question about the guts of PerlIO and IPC::Run
by blahblah (Friar) on Sep 23, 2006 at 15:12 UTC
    You said:
    /opt/perl/lib/site_perl/5.8.5/IPC/Run.pm:2613 Cannot flush f=0x805defc here is line 2513 in my version of Run.pm:

    You are looking at the wrong line. The error message is at 2613, not 2513.

    Update: Apparently OP corrected the line number. Unfortunately I don't have a better answer, but good luck!

      Sorry, didn't have time to respond directly to you. I didn't have easy access to my development environment over the weekend and I was 99% sure it was just a typo so I just changed it in the OP and waited until I got in and had a minute to loop it up again to make sure. Thanks for the catch, and sorry for the roundabout manner in which I responded to your post.

      Terrence

      _________________________________________________________________________________

      I like computer programming because it's like Legos for the mind.