|
Message-ID: <20141213000223.GA530@muslin> Date: Fri, 12 Dec 2014 16:02:24 -0800 From: Isaac Dunham <ibid.ag@...il.com> To: musl@...ts.openwall.com Subject: Re: possible getopt stderr output changes 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
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.