level2: fix first couple of bits
authorAlan Cox <alan@linux.intel.com>
Sat, 9 Jan 2016 19:38:31 +0000 (19:38 +0000)
committerAlan Cox <alan@linux.intel.com>
Sat, 9 Jan 2016 19:38:31 +0000 (19:38 +0000)
Applications/util/init.c
Kernel/level2.c

index b76fedf..a9b4e73 100644 (file)
@@ -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)
index 41d8d90..af3b757 100644 (file)
@@ -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;