summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty_pts.c
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2008-08-22 10:40:21 +0000
committered <ed@FreeBSD.org>2008-08-22 10:40:21 +0000
commit7c4fe3955e6f6e21209b7d30754f9f07ac12f1af (patch)
tree6584ebe1656b550cf8be810b9f152727959b6fe4 /sys/kern/tty_pts.c
parent958ba94773af71ad6ee87a0be93b8b60ad679b3f (diff)
downloadFreeBSD-src-7c4fe3955e6f6e21209b7d30754f9f07ac12f1af.zip
FreeBSD-src-7c4fe3955e6f6e21209b7d30754f9f07ac12f1af.tar.gz
Fix pts(4) error codes when slave device is closed.
Unlike pre-MPSAFE TTY, the pts(4) driver always returned ENXIO when a read() or write() was performed on a pseudo-terminal master device when the slave device was not opened. The old implementation had different semantics: - When the slave device had not been opened yet, read() and write() just blocked. - When the slave device had been closed, a read() call would return 0 bytes length. - When the slave device had been closed, a write() call would return EIO. Change the new implementation to return 0 and EIO as well. We don't implement the first rule, but I suspect this is not needed, because routines like openpty() also open the slave device node. posix_openpt() users also do similar things. Reported by: rink Tested by: rink
Diffstat (limited to 'sys/kern/tty_pts.c')
-rw-r--r--sys/kern/tty_pts.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/sys/kern/tty_pts.c b/sys/kern/tty_pts.c
index 8a51448..ee2a9fe 100644
--- a/sys/kern/tty_pts.c
+++ b/sys/kern/tty_pts.c
@@ -135,10 +135,8 @@ ptsdev_read(struct file *fp, struct uio *uio, struct ucred *active_cred,
break;
/* Maybe the device isn't used anyway. */
- if (tty_opened(tp) == 0) {
- error = ENXIO;
+ if (tty_opened(tp) == 0)
break;
- }
/* Wait for more data. */
if (fp->f_flag & O_NONBLOCK) {
@@ -204,7 +202,7 @@ ptsdev_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
/* Maybe the device isn't used anyway. */
if (tty_opened(tp) == 0) {
- error = ENXIO;
+ error = EIO;
goto done;
}
OpenPOWER on IntegriCloud