From: Isaac Dunham <ibid.ag@gmail.com>
To: musl@lists.openwall.com
Subject: Re: possible getopt stderr output changes
Date: Fri, 12 Dec 2014 16:02:24 -0800 [thread overview]
Message-ID: <20141213000223.GA530@muslin> (raw)
In-Reply-To: <20141211220756.GZ4574@brightrain.aerifal.cx>
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
next prev parent reply other threads:[~2014-12-13 0:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-11 0:10 Rich Felker
2014-12-11 3:53 ` Laurent Bercot
2014-12-11 6:44 ` Rich Felker
2014-12-11 15:40 ` Laurent Bercot
2014-12-11 17:51 ` stdio [de]merits discussion [Re: [musl] possible getopt stderr output changes] Rich Felker
2014-12-11 23:05 ` Laurent Bercot
2014-12-11 23:35 ` Rich Felker
2014-12-12 2:33 ` Morten Welinder
2014-12-11 22:07 ` possible getopt stderr output changes Rich Felker
2014-12-13 0:02 ` Isaac Dunham [this message]
2014-12-13 3:11 ` Rich Felker
2014-12-19 21:49 ` Rich Felker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141213000223.GA530@muslin \
--to=ibid.ag@gmail.com \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).