From owner-freebsd-current@FreeBSD.ORG Sun Dec 21 21:19:52 2008 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 157561065675; Sun, 21 Dec 2008 21:19:52 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: from palm.hoeg.nl (mx0.hoeg.nl [IPv6:2001:7b8:613:100::211]) by mx1.freebsd.org (Postfix) with ESMTP id A95298FC1F; Sun, 21 Dec 2008 21:19:51 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: by palm.hoeg.nl (Postfix, from userid 1000) id B416A1CE1E; Sun, 21 Dec 2008 22:19:49 +0100 (CET) Date: Sun, 21 Dec 2008 22:19:49 +0100 From: Ed Schouten To: Norikatsu Shigemura Message-ID: <20081221211949.GS1176@hoeg.nl> References: <20081221012752.cdc5cbfc.nork@FreeBSD.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="XabuzTTlKwS6ZQpP" Content-Disposition: inline In-Reply-To: <20081221012752.cdc5cbfc.nork@FreeBSD.org> User-Agent: Mutt/1.5.18 (2008-05-17) Cc: FreeBSD Current Subject: Re: Change select(2) to kevent(2) on script(1)... X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 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, 21 Dec 2008 21:19:52 -0000 --XabuzTTlKwS6ZQpP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Norikatsu Shigemura wrote: > I inspired by your 'kqueue()-support to pseudo-terminal master > devices' (svn commit: r185942). So I'm trying to use kevent(2) > on script(1). (SEE ALSO following patch) >=20 > But it doesn't work. Because 'master' file descriptor (from > openpty(3)) doesn't return last 0 byte data readable when shell > exit. In this case of select(2), 'master' file descriptor > gets 0 byte data and exit script(1). >=20 > Do you have any idea? I sure have. It turns out there is a small bug in the pts(4) driver. Inside ptsdrv_close() (called when the TTY is being closed), we set a flag to mark the pseudo-terminal as `finished' (which causes it to return EOF's). A difference between select() and kqueue() is that the knote handlers are executed syncrhonously, while select() calls ptsdev_poll() later on. This should be fixed as of r186382. Thanks for reporting this issue! Are you planning to commit the patch for script(1) to SVN? I'm not sure if we should port applications to kqueue(). Right now script(1) should almost cleanly compile/work on other versions of FreeBSD and other Unix-like operating systems. --=20 Ed Schouten WWW: http://80386.nl/ --XabuzTTlKwS6ZQpP Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAklOsvUACgkQ52SDGA2eCwWXEQCfa4dSPStpxJeWU1hHi7V9h3pE +D8An2aRhQI4wPpxb1iK4nI1XgaynZMT =aqQG -----END PGP SIGNATURE----- --XabuzTTlKwS6ZQpP--