PERFORCE change 146624 for review
Ed Schouten
ed at FreeBSD.org
Mon Aug 4 14:32:11 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=146624
Change 146624 by ed at ed_flippo on 2008/08/04 14:31:46
The POSIX onlinepubs stated:
Any subsequent read from the terminal device shall
return the value of zero, indicating end-of-file; see
read().
The current TTY code already did this, but only after the read()
was started after switching to the zombie state. Move the zombie
state handling just before going to sleep.
Affected files ...
.. //depot/projects/mpsafetty/sys/kern/tty_ttydisc.c#6 edit
Differences ...
==== //depot/projects/mpsafetty/sys/kern/tty_ttydisc.c#6 (text+ko) ====
@@ -146,6 +146,8 @@
if (clen == 0) {
if (ioflag & IO_NDELAY)
return (EWOULDBLOCK);
+ else if (tp->t_flags & TF_ZOMBIE)
+ return (0);
error = tty_wait(tp, &tp->t_inwait);
if (error)
@@ -195,6 +197,9 @@
/* We have to wait for more */
if (ioflag & IO_NDELAY)
return (EWOULDBLOCK);
+ else if (tp->t_flags & TF_ZOMBIE)
+ return (0);
+
error = tty_wait(tp, &tp->t_inwait);
if (error)
return (error);
@@ -202,7 +207,8 @@
}
static int
-ttydisc_read_raw_read_timer(struct tty *tp, struct uio *uio, int ioflag, int oresid)
+ttydisc_read_raw_read_timer(struct tty *tp, struct uio *uio, int ioflag,
+ int oresid)
{
size_t vmin = MAX(tp->t_termios.c_cc[VMIN], 1);
unsigned int vtime = tp->t_termios.c_cc[VTIME];
@@ -239,12 +245,12 @@
*/
if (ioflag & IO_NDELAY)
return (EWOULDBLOCK);
+ else if (tp->t_flags & TF_ZOMBIE)
+ return (0);
+
error = tty_timedwait(tp, &tp->t_inwait, hz);
- if (error == EWOULDBLOCK) {
- return (0);
- } else if (error) {
+ if (error)
return (error);
- }
}
return (0);
@@ -284,6 +290,9 @@
/* We have to wait for more */
if (ioflag & IO_NDELAY)
return (EWOULDBLOCK);
+ else if (tp->t_flags & TF_ZOMBIE)
+ return (0);
+
error = tty_wait(tp, &tp->t_inwait);
if (error)
return (error);
@@ -300,7 +309,7 @@
tty_lock_assert(tp, MA_OWNED);
- if (uio->uio_resid == 0 || tp->t_flags & TF_ZOMBIE)
+ if (uio->uio_resid == 0)
return (0);
if (CMP_FLAG(l, ICANON))
@@ -308,7 +317,8 @@
else if (tp->t_termios.c_cc[VTIME] == 0)
error = ttydisc_read_raw_no_timer(tp, uio, ioflag);
else if (tp->t_termios.c_cc[VMIN] == 0)
- error = ttydisc_read_raw_read_timer(tp, uio, ioflag, uio->uio_resid);
+ error = ttydisc_read_raw_read_timer(tp, uio, ioflag,
+ uio->uio_resid);
else
error = ttydisc_read_raw_interbyte_timer(tp, uio, ioflag);
More information about the p4-projects
mailing list