From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KNOZk-0004zu-CW for qemu-devel@nongnu.org; Mon, 28 Jul 2008 04:59:29 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KNOZg-0004zE-56 for qemu-devel@nongnu.org; Mon, 28 Jul 2008 04:59:26 -0400 Received: from [199.232.76.173] (port=47338 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KNOZe-0004z8-UX for qemu-devel@nongnu.org; Mon, 28 Jul 2008 04:59:23 -0400 Received: from mx1.redhat.com ([66.187.233.31]:56851) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KNOZe-0002fF-Lm for qemu-devel@nongnu.org; Mon, 28 Jul 2008 04:59:22 -0400 Message-ID: <488D8837.2090205@redhat.com> Date: Mon, 28 Jul 2008 10:49:59 +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: <48874D4A.8000604@codemonkey.ws> <48875849.60200@redhat.com> <200807231744.28969.paul@codesourcery.com> <48897D83.9020707@redhat.com> <20080725161714.GA11760@shareable.org> In-Reply-To: <20080725161714.GA11760@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 Cc: Paul Brook Jamie Lokier wrote: > Gerd Hoffmann wrote: >> Fundamental problem is there is no easy way to figure whenever we are >> connected or not. Well, detecting the "connected -> disconnected" >> transition is easy, as read() starts giving us -EIO then. The >> problematic case is the "(initial state | disconnected) -> >> (re-)connected" transition. We have to try read() now and then to check >> whenever we still get -EIO or not. > > Btw, I've just tested. In the initial state, the tty side never > opened, read() blocks and poll/select report that it's not ready for > read. You still don't know whenever someone is connected or not. And thus you still don't know whenever the stuff you write to the tty is read out by someone or you risk to block when the kernel buffer is full. Also note that openpty() which is used by qemu gives you an open file handle for the tty side, so there is no "tty never opened" state. cheers, Gerd -- http://kraxel.fedorapeople.org/xenner/