aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-01-29 22:03:46 +1000
committerDavid Walter Seikel2014-01-29 22:03:46 +1000
commit94fd17d09e75e67434aab1fb529719bdb7aa33a1 (patch)
treeee5d17c0b6a15b9d28a6da384aae989b2b437f65
parentRevert the signal catcher code as promised. (diff)
downloadboxes-94fd17d09e75e67434aab1fb529719bdb7aa33a1.zip
boxes-94fd17d09e75e67434aab1fb529719bdb7aa33a1.tar.gz
boxes-94fd17d09e75e67434aab1fb529719bdb7aa33a1.tar.bz2
boxes-94fd17d09e75e67434aab1fb529719bdb7aa33a1.tar.xz
Better way to deal with the signals, tell the terminal not to send them.
-rw-r--r--boxes.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/boxes.c b/boxes.c
index 3a09858..fc429fc 100644
--- a/boxes.c
+++ b/boxes.c
@@ -2805,13 +2805,42 @@ void boxes_main(void)
2805 ECHOK If ICANON is also set, the KILL character erases the current line. 2805 ECHOK If ICANON is also set, the KILL character erases the current line.
2806 ECHONL If ICANON is also set, echo the NL character even if ECHO is not set. 2806 ECHONL If ICANON is also set, echo the NL character even if ECHO is not set.
2807 TOSTOP Send the SIGTTOU signal to the process group of a background process which tries to write to its controlling terminal. 2807 TOSTOP Send the SIGTTOU signal to the process group of a background process which tries to write to its controlling terminal.
2808 ICANON Enable canonical mode. This enables the special characters EOF, EOL, EOL2, ERASE, KILL, LNEXT, REPRINT, STATUS, and WERASE, and buffers by lines. 2808 ICANON Enable canonical mode. This enables the special characters EOF, EOL, EOL2, ERASE, KILL, LNEXT, REPRINT, STATUS, and WERASE, and buffers by lines.
2809 2809
2810 VTIME Timeout in deciseconds for non-canonical read. 2810 VTIME Timeout in deciseconds for non-canonical read.
2811 VMIN Minimum number of characters for non-canonical read. 2811 VMIN Minimum number of characters for non-canonical read.
2812
2813 raw mode turning off ICANON, IEXTEN, and ISIG kills most special key processing.
2814 termio.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
2815 termio.c_oflag &= ~OPOST;
2816 termio.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
2817 termio.c_cflag &= ~(CSIZE | PARENB);
2818 termio.c_cflag |= CS8;
2819
2820 IGNBRK ignore BREAK
2821 BRKINT complicated, bet in this context, sends BREAK as '\x00'
2822 PARMRK characters with parity or frame erors are sent as '\x00'
2823 ISTRIP strip 8th byte
2824 INLCR translate LF to CR in input
2825 IGLCR ignore CR
2826 OPOST enable implementation defined output processing
2827 ISIG generate signals on INTR (SIGINT on ^C), QUIT (SIGQUIT on ^\\), SUSP (SIGTSTP on ^Z), DSUSP (SIGTSTP on ^Y)
2828 IEXTEN enable implementation defined input processing, turns on some key -> signal -tuff
2829 CSIZE mask for character sizes, so in this case, we mask them all out
2830 PARENB enable parity
2831 CS8 8 bit characters
2832
2833 VEOF "sends" EOF on ^D
2834 VSTART restart output on ^Q, IXON turns that on.
2835 VSTATUS display status info and sends SIGINFO on ^T. Not in POSIX, not supported in Linux. Does not seem to be any method of turning it off where it is supported.
2836 VSTOP stop output on ^S, IXON turns that on.
2837
2812 */ 2838 */
2813 termio.c_iflag &= ~(IUCLC|IXON|IXOFF|IXANY); 2839 termio.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IUCLC | IXON | IXOFF | IXANY);
2814 termio.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|TOSTOP|ICANON); 2840 termio.c_oflag &= ~OPOST;
2841 termio.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL | TOSTOP | ICANON | ISIG | IEXTEN);
2842 termio.c_cflag &= ~(CSIZE | PARENB);
2843 termio.c_cflag |= CS8;
2815 termio.c_cc[VTIME]=0; // deciseconds. 2844 termio.c_cc[VTIME]=0; // deciseconds.
2816 termio.c_cc[VMIN]=1; 2845 termio.c_cc[VMIN]=1;
2817 tcsetattr(0, TCSANOW, &termio); 2846 tcsetattr(0, TCSANOW, &termio);