From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/429 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Anti-bloat side project Date: Tue, 16 Aug 2011 09:52:32 -0400 Message-ID: <20110816135232.GR132@brightrain.aerifal.cx> References: <20110627211909.GZ12592@brightrain.aerifal.cx> <20110627213805.GD5036@port70.net> <20110627213739.GA12592@brightrain.aerifal.cx> <20110627214300.GB12592@brightrain.aerifal.cx> <20110629141945.GL5036@port70.net> <20110629192736.GG12592@brightrain.aerifal.cx> <20110629200358.GN5036@port70.net> <20110816130350.GF26140@barfooze.de> <20110816130643.GQ132@brightrain.aerifal.cx> <20110816131610.GG26140@barfooze.de> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1313502814 8084 80.91.229.12 (16 Aug 2011 13:53:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 16 Aug 2011 13:53:34 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-430-gllmg-musl=m.gmane.org@lists.openwall.com Tue Aug 16 15:53:30 2011 Return-path: Envelope-to: gllmg-musl@lo.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by lo.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1QtK5C-0005BG-EH for gllmg-musl@lo.gmane.org; Tue, 16 Aug 2011 15:53:30 +0200 Original-Received: (qmail 30427 invoked by uid 550); 16 Aug 2011 13:53:29 -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 30419 invoked from network); 16 Aug 2011 13:53:29 -0000 Content-Disposition: inline In-Reply-To: <20110816131610.GG26140@barfooze.de> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:429 Archived-At: On Tue, Aug 16, 2011 at 03:16:10PM +0200, Moritz Wilhelmy wrote: > On Tue, Aug 16, 2011 at 09:06:43 -0400, Rich Felker wrote: > > Is it possibly implemented as a shell script? The way the shell "read" > > command works, it's required to perform byte-at-a-time reads like > > this. Otherwise, I'm guessing someone just foolishly turned off > > buffering on the FILE... > > In fact, it really is a C program, and sadly, it seems they really > implement it that way (by greping over the code for about 30 seconds); > > See src/mygetline.c on hg tip[1]: > 41 while(1) { > 42 res = read(fd, &ch, 1); > > Maybe coders need to be educated about how not to write code in order to > avoid (syscall-)bloat? > > [1]: http://mlmmj.org/hg/mlmmj/file/tip/src/mygetline.c As they're using a file descriptor rather than a FILE or their own higher-level buffering structure, the design forces them to either require that the file descriptor be seekable (so they can seek back after reading too much) or read one byte at a time. I'm not sure why someone would use file descriptors rather than stdio or something similar for processing text.. Looks lke just a bad design. There's no immediate fix, however, as the issue is a result of the design. Rich