stop assuming the interrupt key is [ctrl-C]

The recent discussion around allowing the user to change various termios
(i.e., stty) settings reminded me that there are places in our code
where we assume the interrupt key is [ctrl-C]. That's a bad assumption.
Instead use the actual value reported to us by the kernel.

This also makes the fkr program friendlier by always reporting when a
signal was received, not just when run with -d2, and prompting the user
to press the INTR or EOF key a second time to exit.
This commit is contained in:
Kurtis Rader
2016-12-19 16:11:36 -08:00
parent e8c18386c8
commit 40fa0d5c83
2 changed files with 24 additions and 11 deletions

View File

@@ -4,6 +4,7 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
#include <wchar.h>
#include <wctype.h>
@@ -291,8 +292,7 @@ static int interrupt_handler() {
if (job_reap(1)) reader_repaint_needed();
// Tell the reader an event occured.
if (reader_reading_interrupted()) {
// Return 3, i.e. the character read by a Control-C.
return 3;
return shell_modes.c_cc[VINTR];
}
return R_NULL;