summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/console.c24
-rw-r--r--defaultenv/defaultenv-2-base/bin/init2
-rw-r--r--include/console.h3
3 files changed, 29 insertions, 0 deletions
diff --git a/common/console.c b/common/console.c
index b6685ec..406722a 100644
--- a/common/console.c
+++ b/common/console.c
@@ -575,6 +575,7 @@ void console_flush(void)
EXPORT_SYMBOL(console_flush);
static int ctrlc_abort;
+static int ctrlc_allowed;
void ctrlc_handled(void)
{
@@ -586,6 +587,9 @@ int ctrlc(void)
{
int ret = 0;
+ if (!ctrlc_allowed)
+ return 0;
+
if (ctrlc_abort)
return 1;
@@ -605,5 +609,25 @@ int ctrlc(void)
}
EXPORT_SYMBOL(ctrlc);
+static int console_ctrlc_init(void)
+{
+ globalvar_add_simple_bool("console.ctrlc_allowed", &ctrlc_allowed);
+ return 0;
+}
+device_initcall(console_ctrlc_init);
+
+void console_ctrlc_allow(void)
+{
+ ctrlc_allowed = 1;
+}
+
+void console_ctrlc_forbid(void)
+{
+ ctrlc_allowed = 0;
+}
+
+BAREBOX_MAGICVAR_NAMED(global_console_ctrlc_allowed, global.console.ctrlc_allowed,
+ "If true, scripts can be aborted with ctrl-c");
+
BAREBOX_MAGICVAR_NAMED(global_linux_bootargs_console, global.linux.bootargs.console,
"console= argument for Linux from the stdout-path property in /chosen node");
diff --git a/defaultenv/defaultenv-2-base/bin/init b/defaultenv/defaultenv-2-base/bin/init
index 8d02e3d..a5d3a98 100644
--- a/defaultenv/defaultenv-2-base/bin/init
+++ b/defaultenv/defaultenv-2-base/bin/init
@@ -60,6 +60,8 @@ if [ "$autoboot" = 0 ]; then
autoboot="$?"
fi
+global.console.ctrlc_allowed=true
+
if [ "${key}" = "q" ]; then
exit
fi
diff --git a/include/console.h b/include/console.h
index 6739213..4062e5a 100644
--- a/include/console.h
+++ b/include/console.h
@@ -207,4 +207,7 @@ static inline void pbl_set_putc(void (*putcf)(void *ctx, int c), void *ctx) {}
bool console_allow_color(void);
+void console_ctrlc_allow(void);
+void console_ctrlc_forbid(void);
+
#endif