From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6379 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Why stdout_write checks for terminal? Date: Tue, 21 Oct 2014 11:17:27 -0400 Message-ID: <20141021151727.GD22465@brightrain.aerifal.cx> References: <20141021145640.GA5781@zx-spectrum.accesssoftek.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1413904670 31877 80.91.229.3 (21 Oct 2014 15:17:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 21 Oct 2014 15:17:50 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-6392-gllmg-musl=m.gmane.org@lists.openwall.com Tue Oct 21 17:17:43 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1XgbBt-0005HU-U7 for gllmg-musl@plane.gmane.org; Tue, 21 Oct 2014 17:17:42 +0200 Original-Received: (qmail 13373 invoked by uid 550); 21 Oct 2014 15:17:40 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 13365 invoked from network); 21 Oct 2014 15:17:40 -0000 Content-Disposition: inline In-Reply-To: <20141021145640.GA5781@zx-spectrum.accesssoftek.com> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:6379 Archived-At: 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