Path: utzoo!mnetor!tmsoft!torsqnt!hybrid!scifi!bywater!uunet!st-andy!larry From: larry@st-andy.uucp (Larry Martell) Newsgroups: comp.lang.c Subject: Re: Making chars disappear Message-ID: <1991Feb25.150849.859@st-andy.uucp> Date: 25 Feb 91 15:08:49 GMT References: <8531@castle.ed.ac.uk> Reply-To: uunet!st-andy!larry (Larry Martell) Distribution: comp Organization: RMJ Securities Corp. Lines: 44 In article <8531@castle.ed.ac.uk> james@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 #include 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