tty: fix leakage of -ERESTARTSYS to userland
[linux-2.6-block.git] / drivers / char / n_tty.c
index 2bdb0144a22e3f0b4d8675826bdd0ea353ac3079..154f42203b0569c4f53c306376c6720e73cfa33d 100644 (file)
@@ -579,8 +579,8 @@ static void eraser(unsigned char c, struct tty_struct *tty)
  
 static inline void isig(int sig, struct tty_struct *tty, int flush)
 {
-       if (tty->pgrp > 0)
-               kill_pg(tty->pgrp, sig, 1);
+       if (tty->pgrp)
+               kill_pgrp(tty->pgrp, sig, 1);
        if (flush || !L_NOFLSH(tty)) {
                n_tty_flush_buffer(tty);
                if (tty->driver->flush_buffer)
@@ -1184,13 +1184,14 @@ static int job_control(struct tty_struct *tty, struct file *file)
        /* don't stop on /dev/console */
        if (file->f_op->write != redirected_tty_write &&
            current->signal->tty == tty) {
-               if (tty->pgrp <= 0)
-                       printk("read_chan: tty->pgrp <= 0!\n");
-               else if (process_group(current) != tty->pgrp) {
+               if (!tty->pgrp)
+                       printk("read_chan: no tty->pgrp!\n");
+               else if (task_pgrp(current) != tty->pgrp) {
                        if (is_ignored(SIGTTIN) ||
-                           is_orphaned_pgrp(process_group(current)))
+                           is_current_pgrp_orphaned())
                                return -EIO;
-                       kill_pg(process_group(current), SIGTTIN, 1);
+                       kill_pgrp(task_pgrp(current), SIGTTIN, 1);
+                       set_thread_flag(TIF_SIGPENDING);
                        return -ERESTARTSYS;
                }
        }
@@ -1544,21 +1545,18 @@ static unsigned int normal_poll(struct tty_struct * tty, struct file * file, pol
 }
 
 struct tty_ldisc tty_ldisc_N_TTY = {
-       TTY_LDISC_MAGIC,        /* magic */
-       "n_tty",                /* name */
-       0,                      /* num */
-       0,                      /* flags */
-       n_tty_open,             /* open */
-       n_tty_close,            /* close */
-       n_tty_flush_buffer,     /* flush_buffer */
-       n_tty_chars_in_buffer,  /* chars_in_buffer */
-       read_chan,              /* read */
-       write_chan,             /* write */
-       n_tty_ioctl,            /* ioctl */
-       n_tty_set_termios,      /* set_termios */
-       normal_poll,            /* poll */
-       NULL,                   /* hangup */
-       n_tty_receive_buf,      /* receive_buf */
-       n_tty_write_wakeup      /* write_wakeup */
+       .magic           = TTY_LDISC_MAGIC,
+       .name            = "n_tty",
+       .open            = n_tty_open,
+       .close           = n_tty_close,
+       .flush_buffer    = n_tty_flush_buffer,
+       .chars_in_buffer = n_tty_chars_in_buffer,
+       .read            = read_chan,
+       .write           = write_chan,
+       .ioctl           = n_tty_ioctl,
+       .set_termios     = n_tty_set_termios,
+       .poll            = normal_poll,
+       .receive_buf     = n_tty_receive_buf,
+       .write_wakeup    = n_tty_write_wakeup
 };