mailing list of musl libc
 help / color / mirror / code / Atom feed
* Why stdout_write checks for terminal?
@ 2014-10-21 14:56 Sergey Dmitrouk
  2014-10-21 14:59 ` Josiah Worcester
  2014-10-21 15:17 ` Rich Felker
  0 siblings, 2 replies; 4+ messages in thread
From: Sergey Dmitrouk @ 2014-10-21 14:56 UTC (permalink / raw)
  To: musl

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.

Regards,
Sergey


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Why stdout_write checks for terminal?
  2014-10-21 14:56 Why stdout_write checks for terminal? Sergey Dmitrouk
@ 2014-10-21 14:59 ` Josiah Worcester
  2014-10-21 15:17 ` Rich Felker
  1 sibling, 0 replies; 4+ messages in thread
From: Josiah Worcester @ 2014-10-21 14:59 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 725 bytes --]

On Tue, Oct 21, 2014 at 9:56 AM, Sergey Dmitrouk <sdmitrouk@accesssoftek.com
> 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.
>
> Regards,
> Sergey
>

From the spec <
http://pubs.opengroup.org/onlinepubs/009695399/functions/stdin.html>:  "the
standard input and standard output streams are fully buffered if and only
if the stream can be determined not to refer to an interactive device."

[-- Attachment #2: Type: text/html, Size: 1210 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Why stdout_write checks for terminal?
  2014-10-21 14:56 Why stdout_write checks for terminal? Sergey Dmitrouk
  2014-10-21 14:59 ` Josiah Worcester
@ 2014-10-21 15:17 ` Rich Felker
  2014-10-21 15:40   ` Sergey Dmitrouk
  1 sibling, 1 reply; 4+ messages in thread
From: Rich Felker @ 2014-10-21 15:17 UTC (permalink / raw)
  To: musl

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.

Rich


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Why stdout_write checks for terminal?
  2014-10-21 15:17 ` Rich Felker
@ 2014-10-21 15:40   ` Sergey Dmitrouk
  0 siblings, 0 replies; 4+ messages in thread
From: Sergey Dmitrouk @ 2014-10-21 15:40 UTC (permalink / raw)
  To: musl

On Tue, Oct 21, 2014 at 08:17:27AM -0700, Rich Felker wrote:
> 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.

Thanks for the explanation (and to Josiah as well), that makes sense.
Related commit message is missing details and it wasn't really clear
why this change is needed.

Regards,
Sergey


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-10-21 15:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-21 14:56 Why stdout_write checks for terminal? Sergey Dmitrouk
2014-10-21 14:59 ` Josiah Worcester
2014-10-21 15:17 ` Rich Felker
2014-10-21 15:40   ` Sergey Dmitrouk

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).