bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnulib] getpass echoes on many systems


From: Paul Eggert
Subject: Re: [Bug-gnulib] getpass echoes on many systems
Date: 01 Oct 2003 09:48:40 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Bruno Haible <address@hidden> writes:

> !           /* Write the newline that was not echoed.
> !              But before doing that, do a no-op fseek.  According to the C
> !              standard, input may not be followed by output on the same
> !              stream without an intervening call to a file positioning
> !              function.  Without this fseek() call, on Solaris, HP-UX,
> !              AIX, OSF/1, the previous input gets echoed, whereas on IRIX,
> !              the following newline is not output as it should.  */

The C standard isn't the issue here, surely.  The problem is the
interaction between the input/output streams and applying system calls
like tcsetattr to the underlying file descriptors.  This matter is
covered by POSIX, not by the C standard.

The relevant section of POSIX is the "Interaction of File Descriptors
and Standard I/O Streams"
<http://www.opengroup.org/onlinepubs/007904975/functions/xsh_chap02_05.html#tag_02_05_01>.
As I read it, the correct fix is to arrange for the input stream to be
unbuffered, and that the solution that you just installed may work on
Solaris, IRIX, etc., but it has undefined behavior in general.

Unfortunately, this part of POSIX is pretty hard to grok; perhaps I've
gotten it wrrong.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]