From patchwork Wed Dec 2 15:15:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 551406 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3A65214030F for ; Thu, 3 Dec 2015 02:16:29 +1100 (AEDT) Received: from localhost ([::1]:58676 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a498t-0004vb-AB for incoming@patchwork.ozlabs.org; Wed, 02 Dec 2015 10:16:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a498M-0003uI-Kx for qemu-devel@nongnu.org; Wed, 02 Dec 2015 10:15:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a498I-0007i6-Qm for qemu-devel@nongnu.org; Wed, 02 Dec 2015 10:15:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36938) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a498I-0007i2-Lo for qemu-devel@nongnu.org; Wed, 02 Dec 2015 10:15:50 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 34CFEC0B0210 for ; Wed, 2 Dec 2015 15:15:50 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-40.ams2.redhat.com [10.36.112.40]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tB2FFgL5024962 for ; Wed, 2 Dec 2015 10:15:48 -0500 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 2 Dec 2015 16:15:38 +0100 Message-Id: <1449069340-10419-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1449069340-10419-1-git-send-email-pbonzini@redhat.com> References: <1449069340-10419-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/4] qemu-char: retry g_poll on EINTR X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Reviewed-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); + assert(rc >= 0); + if (pfd.revents & G_IO_HUP) { pty_chr_state(chr, 0); } else {