Making chars disappear

Larry Martell larry at st-andy.uucp
Tue Feb 26 02:08:49 AEST 1991


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 how I do it on a Sun running 4.1:

#include <fcntl.h>
#include <sys/termios.h>

main()

{

int fd;
struct termios  termios;

        if ((fd = open("/dev/tty",O_RDWR)) < 0) {
                perror("open failed\n");
                exit(1);
        }

        if (ioctl(fd,TCGETS,&termios) < 0) {
                perror("ioctl failed\n");
                exit(1);
        }

        termios.c_lflag &= ~ECHO;

        if (ioctl(fd,TCSETS,&termios) < 0) {
                perror("ioctl failed\n");
                exit(1);
        }
}

See termio(4) for more info.
-- 
Larry Martell
uunet!st-andy!larry
212-668-9478



More information about the Comp.lang.c mailing list