[Bug libc/2457] New: Allow control of automatic stdio buffering using env variables

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug libc/2457] New: Allow control of automatic stdio buffering using env variables

fweimer at redhat dot com
I was trying today to filter my access.log apache log with some coreutils
and was annoyed by the default buffering applied by glibc.
I was trying to do `tail -f ~/access.log | cut ... | uniq` but I was
only getting output when cut had more than 4K written to stdout.

So how to control this? Well each app could add an extra config
parameter (see grep --line-buffered for example), but this doesn't
seem general, and just requires duplicating both logic and documentation
for each application. What would be ideal IMHO would be to
add the config logic in glibc (which would have to be controlled
with environment variables). There seems to be resitance to that though:
http://sources.redhat.com/ml/bug-glibc/1999-09/msg00041.html

Anyway whether it's implemented in libc or the application (coreutils lib),
I think they should have the same config interface which would
be environment variables with something like the following format:
    BUF_X_=Y
Where X = the fd number
and Y = 0 for unbuffered, 1 for line buffered and >1 for a specific
buffer size.

So for my particular problem I could do:

tail -f ~/access.log | BUF_1_=1 cut ... | uniq

--
           Summary: Allow control of automatic stdio buffering using env
                    variables
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: enhancement
          Priority: P3
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: P at draigBrady dot com
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=2457

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
Reply | Threaded
Open this post in threaded view
|

[Bug libc/2457] Allow control of automatic stdio buffering using env variables

fweimer at redhat dot com

------- Additional Comments From drepper at redhat dot com  2006-04-02 17:42 -------
Hell, no.  Programs expect a certain buffer mode and perhaps would work
unexpectedly if this changes.  By setting a mode to unbuffered, for instance,
you can easily DoS a system.  I can think about enough other reasons why this is
a terrible idea.  Programs explicitly must request a buffering scheme so that it
matches the way the program uses the stream.

--
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX


http://sourceware.org/bugzilla/show_bug.cgi?id=2457

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.