From owner-freebsd-current@FreeBSD.ORG Sun Jan 2 13:06:32 2005 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9D74516A4CE for ; Sun, 2 Jan 2005 13:06:32 +0000 (GMT) Received: from mail.acropolis.ru (mail.acropolis.ru [81.211.90.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4BDA443D2D for ; Sun, 2 Jan 2005 13:06:31 +0000 (GMT) (envelope-from slw@zxy.spb.ru) Received: from mail.acropolis.ru (localhost.acropolis.ru [127.0.0.1]) by mail.acropolis.ru (8.13.1/8.13.1) with ESMTP id j02D6Q41081325; Sun, 2 Jan 2005 16:06:26 +0300 (MSK) (envelope-from slw@zxy.spb.ru) Received: (from slw@localhost) by mail.acropolis.ru (8.13.1/8.13.1/Submit) id j02D6PkL081324; Sun, 2 Jan 2005 16:06:25 +0300 (MSK) (envelope-from slw@zxy.spb.ru) X-Authentication-Warning: mail.acropolis.ru: slw set sender to slw@zxy.spb.ru using -f Date: Sun, 2 Jan 2005 16:06:25 +0300 From: Slawa Olhovchenkov To: FreeBSD-current@freebsd.org Message-ID: <20050102130625.GA22025@mail.acropolis.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.6i X-Spam-Status: No, hits=-4.9 required=15.0 tests=AWL,BAYES_00 autolearn=ham version=2.63 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on mail.acropolis.ru cc: Poul-Henning Kamp Subject: Hard system hangs on tty code (6-current) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Jan 2005 13:06:32 -0000 6-current totally hangs by this program, from user, not root. No responds on keys pressed, Control-Alt-ESC, switching console and etc. System run in infinite loop in sys/kern/tty.c:ttread() === read: splx(s); /* * Input present, check for input mapping and processing. */ first = 1; if (ISSET(lflag, ICANON | ISIG)) goto slowcase; for (;;) { char ibuf[IBUFSIZ]; int icc; icc = imin(uio->uio_resid, IBUFSIZ); /* XXX uio_resid==0 => icc=0 */ icc = q_to_b(qp, ibuf, icc); /* icc == 0 */ if (icc <= 0) { if (first) goto loop; === #include #include #include #include #include #include #include #include #include #define cfmakeraw(ptr) (ptr)->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR\ |IGNCR|ICRNL|IXON);\ (ptr)->c_oflag &= ~OPOST;\ (ptr)->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);\ (ptr)->c_cflag &= ~(CSIZE|PARENB);\ (ptr)->c_cflag |= CS8 int main(int argc, char *argv[]) { int fd, i; char *buf[1024]; struct termios tcn; if ((fd = open("/dev/tty", O_RDWR | O_NONBLOCK)) == -1) { return -1; /* errno already set */ } /* Set the tty to raw and to the correct speed */ tcgetattr(fd, &tcn); tcn.c_oflag = 0; tcn.c_iflag = IGNBRK | IGNPAR; tcn.c_cflag = CREAD | CLOCAL | CS8; tcn.c_lflag = NOFLSH; cfmakeraw(&tcn); for (i = 0; i < 16; i++) tcn.c_cc[i] = 0; tcn.c_cc[VMIN] = 1; tcn.c_cc[VTIME] = 0; tcsetattr(fd, TCSANOW, &tcn); if ((i = fcntl(fd, F_GETFL, 0)) != -1) { i &= ~O_NONBLOCK; fcntl(fd, F_SETFL, i); } read(fd, buf, 0); } -- Slawa Olhovchenkov