init: create new process group for shell and make it the foreground

This commit is contained in:
Matheus
2024-05-22 09:48:35 -03:00
parent aa6799676b
commit bab8427275
+11
View File
@@ -81,6 +81,17 @@ int main(int argc, char *argv[]) {
}
if (pid == 0) {
// create its own process group and set is as the foreground group
if (setpgid(0, 0) == -1) {
perror("init: setpgrp failed");
return EXIT_FAILURE;
}
if (tcsetpgrp(0, getpid()) == -1) {
perror("init: tcsetpgrp failed");
return EXIT_FAILURE;
}
execl("/usr/bin/bash", "/usr/bin/bash", "-l", NULL);
perror("init: execl /usr/bin/bash failed");
return EXIT_FAILURE;