no echo?
Richard A. O'Keefe
ok at quintus.UUCP
Mon Jan 25 14:51:00 AEST 1988
In article <173 at eutrc3.UUCP>, wswietse at eutrc3.UUCP (Wietse Venema) writes:
> In article <128 at dcrbg1.UUCP>, bcf2303 at dcrbg1.UUCP (Wing Chow) writes:
> > can you tell me how to avoid 'echoing' back to the user what he/she
> > is typing in?
> Questions of this nature often show up in the news group comp.unix.questions.
> Try system("stty -echo"); it should work on all unixes, tho it not
> very efficiently. Try `man tty' for a more efficient implementation.
(1) If you want a method which works under other operating systems,
find out about Curses. The functions
initscr(); /* Start Curses up */
noecho(); /* Turn echoing off */
echo(); /* Turn echoing on */
endwin(); /* Shut Curses down */
are the ones you want. Curses is available under VMS, and there
are several emulations of it around for IBM PCs (there was source
code for one in Dr Dobbs last year).
(2) Whatever you do, DON'T forget to turn echoing back on again!
system("stty echo") is the complement to system("stty -echo").
The easiest way to manage this is to write yourself a function
void my_exit(n)
int n;
{
echo(); /* or whatever */
endwin(); /* other shutting down */
/* delete any scratch files you have open */
exit(n);
}
my_handler()
{
my_exit(1);
}
main()
{
... /* catch all the signals */
signal(SIGQUIT, my_handler); /* that terminate programs */
... /* and make them call your */
signal(SIGTERM, my_handler); /* graceful-exit routine */
...
initscr();
...
}
In any program which creates scratch files you should be doing
something like this anyway. It's a bit of a pain, but believe
me, it's more of a pain to have someone explain your faults
when a program of yours leaves their terminal in a strange
state and they don't know how to get it back.
More information about the Comp.unix.questions
mailing list