Commit | Line | Data |
---|---|---|
56b7f01a SL |
1 | #ifndef lint |
2 | static char *sccsid = "@(#)reset.c 4.4 (Berkeley) %G%"; | |
3 | #endif | |
2b7ef025 | 4 | /* |
38019d2b | 5 | * reset - restore tty to sensible state after crapping out in raw mode. |
2b7ef025 BJ |
6 | */ |
7 | #include <sgtty.h> | |
ebb6a6df | 8 | |
2b7ef025 BJ |
9 | main() |
10 | { | |
11 | struct sgttyb buf; | |
12 | struct tchars tbuf; | |
ebb6a6df | 13 | struct ltchars ltbuf; |
2b7ef025 | 14 | |
56b7f01a | 15 | ioctl(2, TIOCGETP, &buf); |
2b7ef025 | 16 | ioctl(2, TIOCGETC, &tbuf); |
ebb6a6df | 17 | ioctl(2, TIOCGLTC, <buf); |
2b7ef025 BJ |
18 | buf.sg_flags &= ~(RAW|CBREAK|VTDELAY|ALLDELAY); |
19 | buf.sg_flags |= XTABS|ECHO|CRMOD|ANYP; | |
56b7f01a SL |
20 | reset(&buf.sg_erase, CERASE); |
21 | reset(&buf.sg_kill, CKILL); | |
22 | reset(&tbuf.t_intrc, CINTR); | |
23 | reset(&tbuf.t_quitc, CQUIT); | |
24 | reset(&tbuf.t_startc, CSTART); | |
25 | reset(&tbuf.t_stopc, CSTOP); | |
26 | reset(&tbuf.t_eofc, CEOF); | |
27 | reset(<buf.t_suspc, CSUSP); | |
28 | reset(<buf.t_dsuspc, CDSUSP); | |
29 | reset(<buf.t_rprntc, CRPRNT); | |
30 | reset(<buf.t_flushc, CFLUSH); | |
31 | reset(<buf.t_lnextc, CLNEXT); | |
32 | reset(<buf.t_werasc, CWERASE); | |
2b7ef025 BJ |
33 | /* brkc is left alone */ |
34 | ioctl(2, TIOCSETN, &buf); | |
35 | ioctl(2, TIOCSETC, &tbuf); | |
ebb6a6df | 36 | ioctl(2, TIOCSLTC, <buf); |
38019d2b MH |
37 | execlp("tset", "tset", "-Q", "-I", 0); /* fix term dependent stuff */ |
38 | exit(1); | |
ebb6a6df BJ |
39 | } |
40 | ||
41 | reset(cp, def) | |
42 | char *cp; | |
43 | int def; | |
44 | { | |
45 | ||
46 | if (*cp == 0 || (*cp&0377)==0377) | |
47 | *cp = def; | |
2b7ef025 | 48 | } |