liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 6db982f25f30e292ae56e00a28bc9ea5185da42e
parent 86a5224f3c4427f232a98d909330e2815b4cc622
Author: Daniel Barlow <dan@telent.net>
Date:   Sat,  4 Nov 2023 23:56:05 +0000

preinit: pause before exiting

as explained in the comment, this is to give us a
chance to see error messages before the kernel panics

Diffstat:
Mpkgs/preinit/preinit.c | 16++++++++++++++++
1 file changed, 16 insertions(+), 0 deletions(-)

diff --git 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(); }