sandbox: Don't disable ctrlc() on sandbox if in raw mode
authorJoe Hershberger <joe.hershberger@ni.com>
Tue, 3 Jul 2018 01:06:49 +0000 (20:06 -0500)
committerJoe Hershberger <joe.hershberger@ni.com>
Thu, 26 Jul 2018 19:08:17 +0000 (14:08 -0500)
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 <joe.hershberger@ni.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
common/console.c
drivers/serial/sandbox.c

index 36c0568dbffd836f6f74d1759b858ca006a62edd..7aa58d0a63674c21df6ad3ac89445599e498b512 100644 (file)
@@ -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;
 }
index d2e007284c4bb30d4f8a00ea6535bd8fbc2cdb47..a60dabe58835648027ed53d29a715431bea753cd 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <dm.h>
 #include <fdtdec.h>
 #include <lcd.h>
@@ -69,6 +70,9 @@ static int sandbox_serial_probe(struct udevice *dev)
                os_tty_raw(0, state->term_raw == STATE_TERM_RAW_WITH_SIGS);
        priv->start_of_line = 0;
 
+       if (state->term_raw != STATE_TERM_RAW)
+               disable_ctrlc(1);
+
        return 0;
 }