1 static char *sccsid = "@(#)reset.c 4.3 (Berkeley) 12/03/80"; 2 /* 3 * reset - restore tty to sensible state after crapping out in raw mode. 4 */ 5 #include <sgtty.h> 6 7 #define CTRL(x) ('x'&037) 8 9 main() 10 { 11 struct sgttyb buf; 12 struct tchars tbuf; 13 struct ltchars ltbuf; 14 15 gtty(2, &buf); 16 ioctl(2, TIOCGETC, &tbuf); 17 ioctl(2, TIOCGLTC, <buf); 18 buf.sg_flags &= ~(RAW|CBREAK|VTDELAY|ALLDELAY); 19 buf.sg_flags |= XTABS|ECHO|CRMOD|ANYP; 20 reset(&buf.sg_erase, CTRL(h)); 21 reset(&buf.sg_kill, '@'); 22 reset(&tbuf.t_intrc, 0177); 23 reset(&tbuf.t_quitc, CTRL(\\\\)); 24 reset(&tbuf.t_startc, CTRL(q)); 25 reset(&tbuf.t_stopc, CTRL(s)); 26 reset(&tbuf.t_eofc, CTRL(d)); 27 reset(<buf.t_suspc, CTRL(z)); 28 reset(<buf.t_dsuspc, CTRL(y)); 29 reset(<buf.t_rprntc, CTRL(r)); 30 reset(<buf.t_flushc, CTRL(o)); 31 reset(<buf.t_lnextc, CTRL(v)); 32 reset(<buf.t_werasc, CTRL(w)); 33 /* brkc is left alone */ 34 ioctl(2, TIOCSETN, &buf); 35 ioctl(2, TIOCSETC, &tbuf); 36 ioctl(2, TIOCSLTC, <buf); 37 execlp("tset", "tset", "-Q", "-I", 0); /* fix term dependent stuff */ 38 exit(1); 39 } 40 41 reset(cp, def) 42 char *cp; 43 int def; 44 { 45 46 if (*cp == 0 || (*cp&0377)==0377) 47 *cp = def; 48 } 49