Merge branch 'master' of git://git.infradead.org/users/pcmoore/selinux into ra-next
[firefly-linux-kernel-4.4.55.git] / drivers / tty / tty_io.c
index 26bb78c30a00948fb08de571c8001ab9bf86ef36..3a1a01af9a805b38b05f1833eefa80400072f4f4 100644 (file)
@@ -629,6 +629,11 @@ static void __tty_hangup(struct tty_struct *tty, int exit_session)
 
        tty_lock(tty);
 
+       if (test_bit(TTY_HUPPED, &tty->flags)) {
+               tty_unlock(tty);
+               return;
+       }
+
        /* some functions below drop BTM, so we need this bit */
        set_bit(TTY_HUPPING, &tty->flags);
 
@@ -849,7 +854,8 @@ void disassociate_ctty(int on_exit)
                        struct pid *tty_pgrp = tty_get_pgrp(tty);
                        if (tty_pgrp) {
                                kill_pgrp(tty_pgrp, SIGHUP, on_exit);
-                               kill_pgrp(tty_pgrp, SIGCONT, on_exit);
+                               if (!on_exit)
+                                       kill_pgrp(tty_pgrp, SIGCONT, on_exit);
                                put_pid(tty_pgrp);
                        }
                }