From a4e1c49bd13700faba8fff9732a12e9bbc0ef3e7 Mon Sep 17 00:00:00 2001 From: dds Date: Tue, 16 Nov 2004 17:41:16 +0000 Subject: Improvements and fixes in the 1.241 commit: - Have TS_ZOMBIE ttys return POLLHUP instead of POLLERR - Remove unneeded POLLWRNORM (old bug) - TS_ZOMBIE ttys will set POLLIN and POLLRDNORM - Do not call selrecord in TS_ZOMBIE ttys PR: kern/73821 Reviewed by: bde MFC after: 4 weeks --- sys/kern/tty.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'sys') diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 0793e1f..d359f8d 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1283,20 +1283,23 @@ ttypoll(struct cdev *dev, int events, struct thread *td) s = spltty(); if (events & (POLLIN | POLLRDNORM)) { - if (ttnread(tp) > 0) + if (ISSET(tp->t_state, TS_ZOMBIE)) + revents |= (events & (POLLIN | POLLRDNORM)) | + POLLHUP; + else if (ttnread(tp) > 0) revents |= events & (POLLIN | POLLRDNORM); else selrecord(td, &tp->t_rsel); } - if (events & (POLLOUT | POLLWRNORM)) { - if (tp->t_outq.c_cc <= tp->t_olowat && + if (events & POLLOUT) { + if (ISSET(tp->t_state, TS_ZOMBIE)) + revents |= POLLHUP; + else if (tp->t_outq.c_cc <= tp->t_olowat && ISSET(tp->t_state, TS_CONNECTED)) - revents |= events & (POLLOUT | POLLWRNORM); + revents |= events & POLLOUT; else selrecord(td, &tp->t_wsel); } - if (ISSET(tp->t_state, TS_ZOMBIE)) - revents |= POLLERR; splx(s); return (revents); } -- cgit v1.1