simple-init

A set of init binaries for linux
git clone git://depsterr.com/git/simple-init
Log | Files | Refs | README | LICENSE

commit 78e8fdb290cfcfce5737dbcbecb23c65151cfa1f
parent 34d3e07e2fd4d399830324d2258c84a8547f2373
Author: depsterr <depsterr@protonmail.com>
Date:   Sat,  6 Jun 2020 15:42:32 +0200

made ttys respawn

Diffstat:
Minitscripts/init.c | 4++--
Minitscripts/util.c | 10++++++++++
2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/initscripts/init.c b/initscripts/init.c @@ -73,6 +73,6 @@ int main() { log_message("Boot completed, starting ttys"); char* tty1[] = { "/bin/getty", "38400", "tty1", 0 }; char* tty2[] = { "/bin/getty", "38400", "tty2", 0 }; - spawn_process(tty1); - spawn_process(tty2); + respawn_process(tty1); + respawn_process(tty2); } diff --git a/initscripts/util.c b/initscripts/util.c @@ -29,6 +29,16 @@ int spawn_process(char** argv) { return child_pid; } +void respawn_process(char** argv) { + if (fork() == 0) { + int child_pid; + for(;;) { + child_pid = spawn_process(argv); + waitpid(child_pid, 0, 0); + } + } +} + void wait_for_children() { int status = 0; while(wait(&status) > 0) {