From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KLvBe-0003Dr-PJ for qemu-devel@nongnu.org; Thu, 24 Jul 2008 03:24:30 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KLvBe-0003D7-85 for qemu-devel@nongnu.org; Thu, 24 Jul 2008 03:24:30 -0400 Received: from [199.232.76.173] (port=35430 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KLvBd-0003Cz-Tv for qemu-devel@nongnu.org; Thu, 24 Jul 2008 03:24:29 -0400 Received: from mx20.gnu.org ([199.232.41.8]:52694) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KLvBe-00026S-5n for qemu-devel@nongnu.org; Thu, 24 Jul 2008 03:24:30 -0400 Received: from mx1.redhat.com ([66.187.233.31]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KLvBc-0001HP-O8 for qemu-devel@nongnu.org; Thu, 24 Jul 2008 03:24:28 -0400 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m6O7OQa3024158 for ; Thu, 24 Jul 2008 03:24:26 -0400 Received: from pobox.stuttgart.redhat.com (pobox.stuttgart.redhat.com [172.16.2.10]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m6O7OPWW007519 for ; Thu, 24 Jul 2008 03:24:26 -0400 Received: from zweiblum.travel.kraxel.org (vpn-4-35.str.redhat.com [10.32.4.35]) by pobox.stuttgart.redhat.com (8.13.1/8.13.1) with ESMTP id m6O7OPci025789 for ; Thu, 24 Jul 2008 03:24:25 -0400 Message-ID: <48882E28.20805@redhat.com> Date: Thu, 24 Jul 2008 09:24:24 +0200 From: Gerd Hoffmann MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 2/3] Always use nonblocking mode for qemu_chr_open_fd. References: <20080723082413.GA2291@redhat.com> <48871A7E.5030501@redhat.com> <20080723121510.GJ2291@redhat.com> <48872979.4050107@redhat.com> <48873F17.4030101@redhat.com> <48874D4A.8000604@codemonkey.ws> <20080723153133.GL2291@redhat.com> <48874F0B.3040609@codemonkey.ws> <4887598B.8070405@redhat.com> <48875D48.8030906@codemonkey.ws> <20080723190856.GA20800@shareable.org> In-Reply-To: <20080723190856.GA20800@shareable.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Jamie Lokier wrote: > As fas as I know, the usual way to use ptys is a program opens the > pty/tty pair, then it forks/execs a process which will use the tty > half. The child might be the one to open the tty, but it is still > done so the parent knows the tty is open before it tries to use the > pty. Yep, that is what they are designed for (i.e. terminal emulators like screen or xterm keep the pty and hand over the tty to the shell or whatever process they are going to run in the virtual terminal). > To create a pty, and wait without polling for another process to > connect to the tty, this might work: > > 1. Open the pty and tty _pair_, in the usual way. [ ... cut ... ] That would work for the monitor. The problematic corner case are virtual serial lines though. If nobody is connected we don't want to send out data (pretty much like a unconnected socket), so we don't block forever once the output buffer is full. If somebody is listening we want him get all the data (and eventually block in case the reader is slow). cheers, Gerd -- http://kraxel.fedorapeople.org/xenner/