From 1a6a590eee8ab23e0416a56cac0e20db53882ac5 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 12 Jan 2024 14:43:54 +0100 Subject: [PATCH] init: restart the login process after the user session terminated --- programs/init.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/programs/init.c b/programs/init.c index 7292b0a..4406786 100644 --- a/programs/init.c +++ b/programs/init.c @@ -7,18 +7,23 @@ #include #include #include -#include int main(int argc, char *argv[], char *envp[]) { char *_argv[] = { "login", NULL }; int status; - if (fork() == 0) { - execv("/bin/login", _argv); - printf("This is bad, I should not be here! EXEC NOT WORKING\n"); - } + +#pragma clang diagnostic push +#pragma ide diagnostic ignored "EndlessLoop" while (1) { - wait(&status); + pid_t login = fork(); + if (login == 0) { + execv("/bin/login", _argv); + printf("This is bad, I should not be here! EXEC NOT WORKING\n"); + } + + while (wait(&status) != login); } +#pragma clang diagnostic pop return 0; }