From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6712 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: possible getopt stderr output changes Date: Thu, 11 Dec 2014 17:07:56 -0500 Message-ID: <20141211220756.GZ4574@brightrain.aerifal.cx> References: <20141211001032.GA5421@brightrain.aerifal.cx> 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 1418335701 25374 80.91.229.3 (11 Dec 2014 22:08:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 11 Dec 2014 22:08:21 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-6725-gllmg-musl=m.gmane.org@lists.openwall.com Thu Dec 11 23:08:14 2014 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1XzBu7-00075D-7m for gllmg-musl@m.gmane.org; Thu, 11 Dec 2014 23:08:11 +0100 Original-Received: (qmail 31973 invoked by uid 550); 11 Dec 2014 22:08:09 -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 31953 invoked from network); 11 Dec 2014 22:08:09 -0000 Content-Disposition: inline In-Reply-To: <20141211001032.GA5421@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:6712 Archived-At: On Wed, Dec 10, 2014 at 07:10:32PM -0500, Rich Felker wrote: > The current getopt code uses some ugly write() sequences to generate > its output to stderr, and fails to support message translation. The > latter was an oversight when locale/translation support was added and > should absolutely be fixed. I'm not sure whether we should leave the > code using write() though or switch to fprintf. It's been pointed out on irc that POSIX requires ferror(stderr) to be set if writing the message fails. However fwrite could still be used instead of fprintf. If we need to use stdio at all, however, I'd lean towards wanting to make the whole write atomic (i.e. hold the lock for the whole time) which is more of a pain without fprintf. So basically we're looking at: fprintf: PROS: smaller and simpler code in getopt.c, only one syscall CONS: additional ~6.5k of additional code pulled in for static fwrite: PROS: minimal static linking deps CONS: need to use flockfile (or implementation internals) for atomicity if desired, and multiple writes (so no atomicity on the fd) Rich