From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6716 Path: news.gmane.org!not-for-mail From: Isaac Dunham Newsgroups: gmane.linux.lib.musl.general Subject: Re: possible getopt stderr output changes Date: Fri, 12 Dec 2014 16:02:24 -0800 Message-ID: <20141213000223.GA530@muslin> References: <20141211001032.GA5421@brightrain.aerifal.cx> <20141211220756.GZ4574@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 1418428967 16890 80.91.229.3 (13 Dec 2014 00:02:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 13 Dec 2014 00:02:47 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-6729-gllmg-musl=m.gmane.org@lists.openwall.com Sat Dec 13 01:02:40 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 1XzaAO-0005o5-Ui for gllmg-musl@m.gmane.org; Sat, 13 Dec 2014 01:02:37 +0100 Original-Received: (qmail 9456 invoked by uid 550); 13 Dec 2014 00:02:35 -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 9448 invoked from network); 13 Dec 2014 00:02:34 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=LU35/PnFqgpOBkDuJJpnmgETb726Uxr6YW+CYy/0cj0=; b=kF1cq9RzIkB7HmopDqcBHNAIr7bpOJ03wI3OtQsjItw45H9/3lQcD/JqmptGD0a5eQ g215Nr0IzjjQYyfhdXUj1DPCXfHk6JtSBBbVR7yvcy4AAbaD/OLPByXUytjyzefXmJx8 xym3oHcaSdHetCVDTiy2M51Nv5N7d6fTfiT63DyRT7giYneM6t7bb1tzEgM5VsfCBtzt TZy7BDCKdMfiRXNJ011dr7hswS9hZNsv8v+PeT37DRlsIgs+viGvecdHsSodObcQGeCX KC4QT7j1SCpfW25AEnv6LgSHYJ4JfWLH5ZMuWZwbTE0uA5TKT97y9Z1MQc6L2C+2W6iV jOXw== X-Received: by 10.70.126.161 with SMTP id mz1mr31477351pdb.14.1418428942369; Fri, 12 Dec 2014 16:02:22 -0800 (PST) Content-Disposition: inline In-Reply-To: <20141211220756.GZ4574@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:6716 Archived-At: On Thu, Dec 11, 2014 at 05:07:56PM -0500, Rich Felker wrote: > 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) I realize there's quality of implementation to be concerned about and similar issues, but I'm really wondering: How brain-damaged does code have to be to call getopt() from a thread, *after* starting a second thread and beginning writes to stderr? Is there any real-world use of this? Thanks, Isaac Dunham