From owner-p4-projects@FreeBSD.ORG Mon Aug 4 14:32:11 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id F130C1065689; Mon, 4 Aug 2008 14:32:10 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B4846106568C for ; Mon, 4 Aug 2008 14:32:10 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id A73D48FC15 for ; Mon, 4 Aug 2008 14:32:10 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m74EWA0l062100 for ; Mon, 4 Aug 2008 14:32:10 GMT (envelope-from ed@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m74EWAwu062098 for perforce@freebsd.org; Mon, 4 Aug 2008 14:32:10 GMT (envelope-from ed@FreeBSD.org) Date: Mon, 4 Aug 2008 14:32:10 GMT Message-Id: <200808041432.m74EWAwu062098@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to ed@FreeBSD.org using -f From: Ed Schouten To: Perforce Change Reviews Cc: Subject: PERFORCE change 146624 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Aug 2008 14:32:11 -0000 http://perforce.freebsd.org/chv.cgi?CH=146624 Change 146624 by ed@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);