Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 21 Oct 2014 11:17:27 -0400
From: Rich Felker <>
Subject: Re: Why stdout_write checks for terminal?

On Tue, Oct 21, 2014 at 05:56:40PM +0300, Sergey Dmitrouk wrote:
> Hi,
> the code in src/stdio/__stdout_write.c checks whether output is going to
> a terminal and if it's not the case disables line buffering.  I'm
> wondering what's the reason behind this?  This causes some programs to
> produce different output depending whether stdout is terminal or not,
> not a bit deal, but I don't see much profit in disabling buffering
> either.

Full buffering _must_ be disabled if the underlying file is an
"interactive device" (terminal); this is a requirement of the
standards. Somewhere in the distant past musl always put stdout in
line-buffered mode, but users complained (rightfully) because programs
writing binary data to stdout (e.g. things like djpeg) were 10-100x
slower than with other libcs, so now whether it's line or full
buffered depends on whether it's a terminal.


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.