[Toybox] read_password() doesn't print prompt

enh enh at google.com
Tue May 21 09:35:19 PDT 2019


presumably this is musl you're talking about?

iirc:

* BSD-derived implementations (including Android and Apple) take the
spec literally and flush all line-buffered streams before reading from
a line-buffered or unbuffered stream.

* glibc special-cases stdout to keep old code working.

* musl does nothing, making it the caller's responsibility to flush the prompt.

tbh, before i became a libc maintainer i believed it was my
responsibility to flush prompts. it's a rare enough operation that i
still think anything other than adding a handful of flushes that are
actually necessary is an overreaction.

fwiw, we're considering moving Android to either the glibc or musl
behavior in R. the traditional BSD behavior is quite a pessimization
(that doesn't matter for line-buffered streams because you asked for
it, but is pretty sad for _unbuffered_ streams). the musl behavior is
ideal from the libc implementer's perspective, but we were concerned
about how much code we'd affect given that basically all current OSes
have a libc that at least flushes stdout in these cases, so i think
we're more likely to go with the glibc behavior.

On Thu, May 16, 2019 at 5:46 AM Rob Landley <rob at landley.net> wrote:
>
> On 5/16/19 4:03 AM, William Djupström via Toybox wrote:
> > since xprintf() doesn't always flush, if the read_password() message
> > doesn't have a newline at the end, which it usually doesn't, the prompt
> > won't show up until after you've entered your password.
>
> Sigh. This problem makes me said, and it's why I created xprintf() in the first
> place.
>
> What I need is either an alarm() that calls flush if nothing more has been
> printed in half a second or having every input function call fflush(0) first. Or
> to make xprintf() call xflush() again which is why I created xprintf() in the
> first place...
>
> What I really want is a canellable set_timer() function that calls a defined
> function() after a timeout, which won't interfere with existing uses of alarm().
> Unfortunately timer_create() requires -lrt which pulls in pthread on glibc
> now!). I dunno how/why glibc broke that, but maybe I can just write glibc off a
> too broken to care about anymore? Hmmm...
>
> Rob
> _______________________________________________
> Toybox mailing list
> Toybox at lists.landley.net
> http://lists.landley.net/listinfo.cgi/toybox-landley.net



More information about the Toybox mailing list