diff --git a/sys/kern/tty.c b/sys/kern/tty.c index d8a76d9f9b07..a14f71425b2a 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -536,25 +536,23 @@ ttydev_poll(struct cdev *dev, int events, struct thread *td) int error, revents = 0; error = ttydev_enter(tp); - if (error) { - /* Don't return the error here, but the event mask. */ - return (events & - (POLLHUP|POLLIN|POLLRDNORM|POLLOUT|POLLWRNORM)); - } + if (error) + return ((events & (POLLIN|POLLRDNORM)) | POLLHUP); if (events & (POLLIN|POLLRDNORM)) { /* See if we can read something. */ if (ttydisc_read_poll(tp) > 0) revents |= events & (POLLIN|POLLRDNORM); } - if (events & (POLLOUT|POLLWRNORM)) { + + if (tp->t_flags & TF_ZOMBIE) { + /* Hangup flag on zombie state. */ + revents |= POLLHUP; + } else if (events & (POLLOUT|POLLWRNORM)) { /* See if we can write something. */ if (ttydisc_write_poll(tp) > 0) revents |= events & (POLLOUT|POLLWRNORM); } - if (tp->t_flags & TF_ZOMBIE) - /* Hangup flag on zombie state. */ - revents |= events & POLLHUP; if (revents == 0) { if (events & (POLLIN|POLLRDNORM)) diff --git a/sys/kern/tty_pts.c b/sys/kern/tty_pts.c index 0b196dd28134..999472ade42e 100644 --- a/sys/kern/tty_pts.c +++ b/sys/kern/tty_pts.c @@ -409,8 +409,7 @@ ptsdev_poll(struct file *fp, int events, struct ucred *active_cred, if (psc->pts_flags & PTS_FINISHED) { /* Slave device is not opened. */ tty_unlock(tp); - return (events & - (POLLHUP|POLLIN|POLLRDNORM|POLLOUT|POLLWRNORM)); + return ((events & (POLLIN|POLLRDNORM)) | POLLHUP); } if (events & (POLLIN|POLLRDNORM)) {