diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2018-01-08 11:52:15 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2018-01-08 11:52:15 +0000 |
commit | 6d61c2b2fec095e795e7adb2f2e69b0ad0e992ba (patch) | |
tree | 0560ba8dc111de22bdfb12889da95d9ca345d0b6 /sys/kern/tty_pty.c | |
parent | 7992f809e9185a54690683e07e421bd9dd5d9ca0 (diff) |
Translate the TIOCSBRK & TIOCCBRK ioctl(2)s issued on a pty(4) slave to
corresponding user mode ioctls.
If the master part of the pseudo terminal previously enabled TIOCUCNTL,
it will now receive the TIOCUCNTL_{S,C}BRK commands. This allows to
send BREAKS commands over a pty(4) independently of the serial terminal
emulator used.
Guidance and ok nicm@, ok ccardenas@, looks ok to deraadt@
Diffstat (limited to 'sys/kern/tty_pty.c')
-rw-r--r-- | sys/kern/tty_pty.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c index 970cb044942..d16fb827a8c 100644 --- a/sys/kern/tty_pty.c +++ b/sys/kern/tty_pty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty_pty.c,v 1.81 2018/01/02 06:38:45 guenther Exp $ */ +/* $OpenBSD: tty_pty.c,v 1.82 2018/01/08 11:52:14 mpi Exp $ */ /* $NetBSD: tty_pty.c,v 1.33.4.1 1996/06/02 09:08:11 mrg Exp $ */ /* @@ -861,6 +861,20 @@ ptyioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) if (error < 0) error = ttioctl(tp, cmd, data, flag, p); if (error < 0) { + /* + * Translate TIOCSBRK/TIOCCBRK to user mode ioctls to + * let the master interpret BREAK conditions. + */ + switch (cmd) { + case TIOCSBRK: + cmd = UIOCCMD(TIOCUCNTL_SBRK); + break; + case TIOCCBRK: + cmd = UIOCCMD(TIOCUCNTL_CBRK); + break; + default: + break; + } if (pti->pt_flags & PF_UCNTL && (cmd & ~0xff) == UIOCCMD(0)) { if (cmd & 0xff) { |