From be025a563e6cd5fce0b1553de202e9db54b90692 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Thu, 21 May 2015 23:34:17 +0100 Subject: [PATCH] init: enable process groups --- Applications/util/init.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Applications/util/init.c b/Applications/util/init.c index 2636c0f7..8c515679 100644 --- a/Applications/util/init.c +++ b/Applications/util/init.c @@ -89,31 +89,31 @@ int login(char *ttyname) struct passwd *pwd; char *p, buf[50], salt[3]; - fdtty = open(ttyname, O_RDWR); - if (fdtty < 0) return -1; - for (;;) { pid = fork(); if (pid == -1) { putstr("init: can't fork\n"); } else { - if (pid != 0) { - close(fdtty); + if (pid != 0) /* parent's context: return pid of the child process */ return pid; - } - + + close(0); + close(1); + close(2); + setpgrp(); + + fdtty = open(ttyname, O_RDWR); + if (fdtty < 0) + return -1; + /* here we are inside child's context of execution */ envset("PATH", "/bin:/usr/bin"); envset("CTTY", ttyname); /* make stdin, stdout and stderr point to fdtty */ - close(0); dup(fdtty); - close(1); - dup(fdtty); - close(2); dup(fdtty); /* display the /etc/issue file, if exists */ -- 2.34.1