[CALUG] More I/O buffering foolishness

Jason C. Miller jason.c.miller at gmail.com
Wed Mar 1 20:39:22 CST 2006


Arg.  Alright....some more details.  :)

1. It is a Solaris 8 machine
2. My code is not as simple as a single perl print() statement.  That 
was simply there to provide a simple example that doesn't work on my 
system.  It works fine at the command prompt but not from a script 
(which, after more reading, I understand a lot more about how programs 
see what devices STDOUT is attached to and how they act accordingly).
3. As mentioned, it doesn't matter what command (perl, awk, sed, grep, 
etc) comes after that next pipe.  All the STDIN for those programs are 
block-buffered.

Anyhoo.  Yet another day in paradise.  :)


Chris Edillon wrote:

>On Wed, 2006-03-01 at 09:43 -0500, Jason C. Miller wrote:
>
>  
>
>>I've asked a buffering question on here before and have now run into a 
>>similar-yet-different issue and was wondering if anyone had any insight.
>>
>>Here's the short story...
>>
>>
>>At the command line (bash) ...
>>-----------------------------------
>>(cd /blah ; tar cvf - * 2>/dev/null) | (cd /blah2 ; tar xvf - 2>/tmp/log) | \
>>perl -e 'while (<STDIN>) { print }'
>>-----------------------------------
>>... works fine.  All it does is print the stdout from the tar extraction.  
>>
>>    
>>
>  perhaps i'm missing something, but why pipe the output
>to perl?  it's already printing to stdout.
>
>  
>
>>The oddness is that, inside the script ...
>>-----------------------------------
>>(cd /blah ; tar cvf - * 2>/dev/null) | (cd /blah2 ; tar xvf - 2>/tmp/log)
>>-----------------------------------
>>... will line-buffer just fine.  It's when I try to pipe that into
>>anything else AFTER that the buffering issues come up.  I've tried it with
>>both perl and awk and they both do the same thing.  I tried forcing the 
>>flush in the perl, but that doesn't do anything and I really don't know if 
>>that's the issue or not.  
>>
>>    
>>
>  like mark, i can't recreate this either.  i wrote this little snippit
>and it doesn't seem to buffer the output (with or without the perl bit):
>
>#!/bin/sh
>tar -cvf - /usr/share/doc/* 2>/dev/null | (cd /tmp/test && tar -xvf -
>2>/tmp/testlog) | perl -pe ''
>
>if this is input for Xdialog, perhaps it is buffering before
>printing anything?
>
>chris
>
>  
>


-- 
***************************************************
My blog: http://millersplace.blogspot.com/ 
***************************************************



More information about the lug mailing list