aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/pty.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/pty.c')
-rw-r--r--drivers/char/pty.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/char/pty.c b/drivers/char/pty.c
index d83a43130df4..b640ef29be1c 100644
--- a/drivers/char/pty.c
+++ b/drivers/char/pty.c
@@ -171,6 +171,23 @@ static int pty_set_lock(struct tty_struct *tty, int __user *arg)
171 return 0; 171 return 0;
172} 172}
173 173
174/* Send a signal to the slave */
175static int pty_signal(struct tty_struct *tty, int sig)
176{
177 unsigned long flags;
178 struct pid *pgrp;
179
180 if (tty->link) {
181 spin_lock_irqsave(&tty->link->ctrl_lock, flags);
182 pgrp = get_pid(tty->link->pgrp);
183 spin_unlock_irqrestore(&tty->link->ctrl_lock, flags);
184
185 kill_pgrp(pgrp, sig, 1);
186 put_pid(pgrp);
187 }
188 return 0;
189}
190
174static void pty_flush_buffer(struct tty_struct *tty) 191static void pty_flush_buffer(struct tty_struct *tty)
175{ 192{
176 struct tty_struct *to = tty->link; 193 struct tty_struct *to = tty->link;
@@ -321,6 +338,8 @@ static int pty_bsd_ioctl(struct tty_struct *tty, struct file *file,
321 switch (cmd) { 338 switch (cmd) {
322 case TIOCSPTLCK: /* Set PT Lock (disallow slave open) */ 339 case TIOCSPTLCK: /* Set PT Lock (disallow slave open) */
323 return pty_set_lock(tty, (int __user *) arg); 340 return pty_set_lock(tty, (int __user *) arg);
341 case TIOCSIG: /* Send signal to other side of pty */
342 return pty_signal(tty, (int) arg);
324 } 343 }
325 return -ENOIOCTLCMD; 344 return -ENOIOCTLCMD;
326} 345}
@@ -476,6 +495,8 @@ static int pty_unix98_ioctl(struct tty_struct *tty, struct file *file,
476 return pty_set_lock(tty, (int __user *)arg); 495 return pty_set_lock(tty, (int __user *)arg);
477 case TIOCGPTN: /* Get PT Number */ 496 case TIOCGPTN: /* Get PT Number */
478 return put_user(tty->index, (unsigned int __user *)arg); 497 return put_user(tty->index, (unsigned int __user *)arg);
498 case TIOCSIG: /* Send signal to other side of pty */
499 return pty_signal(tty, (int) arg);
479 } 500 }
480 501
481 return -ENOIOCTLCMD; 502 return -ENOIOCTLCMD;