aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2015-12-01 11:27:00 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2015-12-02 12:01:43 +0100
commitc1f2448998062f25df395cd239169400a4c41ed6 (patch)
tree9ea0f0da6d3fc2f5d08ed01b96bf131d52099c37
parent55b4e80b047300e1512df02887b7448ba3786b62 (diff)
qemu-char: retry g_poll on EINTR
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 <armbru@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--qemu-char.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/qemu-char.c b/qemu-char.c
index 5448b0f30b..2969c44e84 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 {