From 5c9e3c833779e7634d68126005c1f83d6b113a7a Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 9 Jan 2016 19:38:31 +0000 Subject: [PATCH] level2: fix first couple of bits --- Applications/util/init.c | 6 ++++++ Kernel/level2.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Applications/util/init.c b/Applications/util/init.c index b76fedf5..a9b4e731 100644 --- a/Applications/util/init.c +++ b/Applications/util/init.c @@ -475,6 +475,11 @@ int main(int argc, char *argv[]) unlink("/etc/mtab"); + /* clean up anything handed to us by the kernel */ + close(0); + close(1); + close(2); + /* loop until we can open the first terminal */ do { @@ -562,6 +567,7 @@ static pid_t getty(const char *ttyname, const char *id) close(1); close(2); setpgrp(); + setpgid(0,0); fdtty = open(ttyname, O_RDWR); if (fdtty < 0) diff --git a/Kernel/level2.c b/Kernel/level2.c index 41d8d90b..af3b7579 100644 --- a/Kernel/level2.c +++ b/Kernel/level2.c @@ -17,7 +17,7 @@ int in_group(uint16_t gid) void jobcontrol_in(struct tty *t) { - if (udata.u_ptab->p_pgrp == t->pgrp) + if (!t->pgrp || udata.u_ptab->p_pgrp == t->pgrp) return; /* We probably want to special case a helper here because we need to handle the funnier side effects ? */ @@ -28,7 +28,7 @@ void jobcontrol_in(struct tty *t) void jobcontrol_out(struct tty *t) { - if (udata.u_ptab->p_pgrp == t->pgrp) + if (!t->pgrp || udata.u_ptab->p_pgrp == t->pgrp) return; if (!(t->termios.c_lflag & TOSTOP)) return; -- 2.34.1