From b2f58d8ee090ccf15b1366ac46a075c02a01f4fc Mon Sep 17 00:00:00 2001 From: Joe Hershberger Date: Mon, 2 Jul 2018 20:06:48 -0500 Subject: console: Remember if ctrlc is disabled in console_tstc() We don't necessarily want to re-enable ctrl-c if it was already disabled when calling tstc(). Signed-off-by: Joe Hershberger Reviewed-by: Simon Glass --- common/console.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'common/console.c') diff --git a/common/console.c b/common/console.c index 2ba33dc5740..36c0568dbff 100644 --- a/common/console.c +++ b/common/console.c @@ -196,20 +196,21 @@ static int console_tstc(int file) { int i, ret; struct stdio_dev *dev; + int prev; - disable_ctrlc(1); + prev = disable_ctrlc(1); for (i = 0; i < cd_count[file]; i++) { dev = console_devices[file][i]; if (dev->tstc != NULL) { ret = dev->tstc(dev); if (ret > 0) { tstcdev = dev; - disable_ctrlc(0); + disable_ctrlc(prev); return ret; } } } - disable_ctrlc(0); + disable_ctrlc(prev); return 0; } -- cgit v1.2.3 From 82a115fdec875d7e8dc601fe0e1b12859814c91c Mon Sep 17 00:00:00 2001 From: Joe Hershberger Date: Mon, 2 Jul 2018 20:06:49 -0500 Subject: sandbox: Don't disable ctrlc() on sandbox if in raw mode In raw mode, handle ctrl-c as normal. This allows normal ctrl-c behavior such as aborting a command that is timing out without completely terminating the sandbox executable. In [1], Simon disabled this. His reason for it was that it interferes with piping test scripts. Piping should be done in cooked mode, so this change should still not interfere. [1] commit 8969ea3e9f2db04a6b3675 ("sandbox: Disable Ctrl-C") Signed-off-by: Joe Hershberger Reviewed-by: Simon Glass --- common/console.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'common/console.c') diff --git a/common/console.c b/common/console.c index 36c0568dbff..7aa58d0a636 100644 --- a/common/console.c +++ b/common/console.c @@ -604,7 +604,6 @@ static int ctrlc_disabled = 0; /* see disable_ctrl() */ static int ctrlc_was_pressed = 0; int ctrlc(void) { -#ifndef CONFIG_SANDBOX if (!ctrlc_disabled && gd->have_console) { if (tstc()) { switch (getc()) { @@ -616,7 +615,6 @@ int ctrlc(void) } } } -#endif return 0; } -- cgit v1.2.3