From 6db982f25f30e292ae56e00a28bc9ea5185da42e Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Sat, 4 Nov 2023 23:56:05 +0000 Subject: [PATCH] preinit: pause before exiting as explained in the comment, this is to give us a chance to see error messages before the kernel panics --- pkgs/preinit/preinit.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkgs/preinit/preinit.c b/pkgs/preinit/preinit.c index d78b2800..89afb97e 100644 --- a/pkgs/preinit/preinit.c +++ b/pkgs/preinit/preinit.c @@ -15,6 +15,21 @@ void parseopts(char * cmdline, char **root, char **rootfstype); #define ERR(x) write(2, x, strlen(x)) #define AVER(c) do { if(c < 0) ERR("failed: " #c); } while(0) +static void die() { + /* if init exits, it causes a kernel panic. On the Turris + * Omnia (and maybe other hardware, I don't know), the kernel + * panics _before_ any of the messages from AVER are printed, + * which makes it really hard to tell what went wrong. So + * let's wait a little here to give the console a chance to + * catch up. + * + * Yes, I know that file descriptor IO is supposedly + * non-buffered. Empirical observation suggests that there + * must be a buffer of some kind somewhere though. + */ + + sleep(10); + exit(1); } static int fork_exec(char * command, char *args[]) @@ -78,4 +93,5 @@ int main(int argc, char *argv[], char *envp[]) argv[1] = NULL; AVER(execve("/persist/init", argv, envp)); } + die(); }