Received: from eggs.gnu.org ([2001:4830:134:3::10]:35957) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3jwa-0005Sg-HK for qemu-devel@nongnu.org; Tue, 01 Dec 2015 07:22:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a3jwX-00005q-5f for qemu-devel@nongnu.org; Tue, 01 Dec 2015 07:22:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52040) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a3jwX-00005d-0M for qemu-devel@nongnu.org; Tue, 01 Dec 2015 07:22:01 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 19938755 for ; Tue, 1 Dec 2015 12:22:00 +0000 (UTC) From: Markus Armbruster References: <1448965656-27220-1-git-send-email-pbonzini@redhat.com> Date: Tue, 01 Dec 2015 13:21:57 +0100 In-Reply-To: <1448965656-27220-1-git-send-email-pbonzini@redhat.com> (Paolo Bonzini's message of "Tue, 1 Dec 2015 11:27:36 +0100") Message-ID: <87io4inyu2.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH for-2.5] qemu-char: retry g_poll on EINTR List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org Paolo Bonzini writes: > This is a case where pty_chr_update_read_handler_locked's lack > of error checking can produce incorrect values. We are not using > SIGUSR1 anymore, so this is quite theoretical, but easy to fix. > > Reported-by: Markus Armbruster > Signed-off-by: Paolo Bonzini > --- > qemu-char.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/qemu-char.c b/qemu-char.c > index 5448b0f..2969c44 100644 > --- a/qemu-char.c > +++ b/qemu-char.c > @@ -1241,11 +1241,16 @@ static void pty_chr_update_read_handler_locked(CharDriverState *chr) > { > PtyCharDriver *s = chr->opaque; > GPollFD pfd; > + int rc; > > pfd.fd = g_io_channel_unix_get_fd(s->fd); > pfd.events = G_IO_OUT; > pfd.revents = 0; > - g_poll(&pfd, 1, 0); > + do { > + rc = g_poll(&pfd, 1, 0); > + } while (rc == -1 && errno == EINTR); Could use TFR(), but that's a matter of taste. Both ways aleady exist in this file. > + assert(rc >= 0); Documented errors other than EINTR: EFAULT The array given as argument was not contained in the calling program's address space. EINVAL The nfds value exceeds the RLIMIT_NOFILE value. ENOMEM There was no space to allocate file descriptor tables. Aborting feels okay to me. > + > if (pfd.revents & G_IO_HUP) { > pty_chr_state(chr, 0); > } else { Reviewed-by: Markus Armbruster