mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 3/5] sandbox: implement simple, ^C-interruptible, restart handler
Date: Mon, 14 Sep 2020 15:37:46 +0200	[thread overview]
Message-ID: <20200914133748.5988-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20200914133748.5988-1-a.fatoum@pengutronix.de>

Typing reset in sandbox results in hang() while the terminal is not
cooked and ^C is ineffective. Only way to terminate barebox then is
via kill. Reinstate cooked mode on reset, so ^C termination is
possible.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/sandbox/board/poweroff.c                  | 12 ++++++++++++
 arch/sandbox/mach-sandbox/include/mach/linux.h |  1 +
 arch/sandbox/os/common.c                       |  6 ++++++
 3 files changed, 19 insertions(+)

diff --git a/arch/sandbox/board/poweroff.c b/arch/sandbox/board/poweroff.c
index 6b5a6dff15f9..5072b756e108 100644
--- a/arch/sandbox/board/poweroff.c
+++ b/arch/sandbox/board/poweroff.c
@@ -1,6 +1,7 @@
 #include <common.h>
 #include <init.h>
 #include <poweroff.h>
+#include <restart.h>
 #include <mach/linux.h>
 
 static void sandbox_poweroff(struct poweroff_handler *poweroff)
@@ -8,9 +9,20 @@ static void sandbox_poweroff(struct poweroff_handler *poweroff)
 	linux_exit();
 }
 
+static void sandbox_rst_hang(struct restart_handler *rst)
+{
+	linux_hang();
+}
+
+static struct restart_handler rst_hang = {
+	.name = "hang",
+	.restart = sandbox_rst_hang
+};
+
 static int poweroff_register_feature(void)
 {
 	poweroff_handler_register_fn(sandbox_poweroff);
+	restart_handler_register(&rst_hang);
 
 	return 0;
 }
diff --git a/arch/sandbox/mach-sandbox/include/mach/linux.h b/arch/sandbox/mach-sandbox/include/mach/linux.h
index 9759a376ecb3..f0a3a7b510fc 100644
--- a/arch/sandbox/mach-sandbox/include/mach/linux.h
+++ b/arch/sandbox/mach-sandbox/include/mach/linux.h
@@ -17,6 +17,7 @@ ssize_t linux_write(int fd, const void *buf, size_t count);
 off_t linux_lseek(int fildes, off_t offset);
 int linux_tstc(int fd);
 void __attribute__((noreturn)) linux_exit(void);
+void linux_hang(void);
 
 int linux_execve(const char * filename, char *const argv[], char *const envp[]);
 
diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index 437fe3ecdff8..bbab3bd2312d 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -122,6 +122,12 @@ void __attribute__((noreturn)) linux_exit(void)
 	exit(0);
 }
 
+void linux_hang(void)
+{
+	cookmode();
+	/* falls through to generic hang() */
+}
+
 int linux_open(const char *filename, int readwrite)
 {
 	return open(filename, readwrite ? O_RDWR : O_RDONLY);
-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2020-09-14 13:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-14 13:37 [PATCH 1/5] lib: string: retire deprecated strtok() in favor of reentrant strsep() Ahmad Fatoum
2020-09-14 13:37 ` [PATCH 2/5] ls: don't print . and .. on recursive ls Ahmad Fatoum
2020-09-14 13:37 ` Ahmad Fatoum [this message]
2020-09-14 13:37 ` [PATCH 4/5] sandbox: implement actual sandbox reset via exec(2) Ahmad Fatoum
2020-09-15  5:21   ` [PATCH] fixup! " Ahmad Fatoum
2020-09-14 13:37 ` [PATCH 5/5] sandbox: hostfile: support registering images as barebox block devices Ahmad Fatoum
2020-09-15  7:26 ` [PATCH 1/5] lib: string: retire deprecated strtok() in favor of reentrant strsep() Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200914133748.5988-3-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox