making characters disappear

Usenet news administrator news at to.rushpc
Tue Feb 19 12:57:27 AEST 1991


In article <1991Feb18.035149.369 at convex.com> tchrist at convex.COM (Tom Christiansen) writes:
>:In article <8531 at castle.ed.ac.uk> james at castle.ed.ac.uk (J Gillespie) writes:
>:>
>:>Does anyone know of a way to prevent characters being echoed as they
>:>are typed in?  Like when you log in, your password doesn't get echoed.
>:>I have a nasty feeling this may involve sending control codes to the
>:>terminal.
>
>This is *not* a C-related question.  It's an OS-related question, and
>cannot be answered portably.  It's very closely related to "how do I get
>one character from the keyboard," which doesn't belong here either.
>

Seems like a perfectly legitimate subject for this news group to me but,
let me have it if I'm wrong.  Recently I've seen postings discussing the
composition of functions in this group, I think they belong in math.college.
algebra.f(x) o g(x) - just kidding.  

I've also wondered how to turn off echo while writing a C program.  I've
RTFM, AT&T's, on ioctl(2) and termio(7).  Finally, I gave up and used the
curses library.  Curses attempts to have portability in it's middle name.
You can turn off echo, make a terminal belch, blink, and ring using curses.

I would not suggest using system("stty raw").  I tried it, just for grins,
and ended up having to power cycle my terminal.  If you must use system(),
try system("stty -echo") to turn off echo, and then system("stty echo") to
turn it back on.

In the original question, he asked how /bin/login managed to turn off
echo.  I believe /bin/login uses getpass(3).  getpass(3), after issuing
a prompt, turns off echo and then accepts up to eight characters typed in
from the keyboard.  Now I'm sure that the subroutine getpass(3) and the
command stty(1), having been written in C Language, use the lower level
ioctl(2) system call.  I myself would like to see an example of it's use
in a C program.

John Rushford.

I had trouble posting this and I hope multiple copies were not sent
to the net.  My apologies if this is the case.



More information about the Comp.lang.c mailing list