qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 2/2] qemu-ga: suspend: handle EINTR


From: Luiz Capitulino
Subject: [Qemu-devel] [PATCH 2/2] qemu-ga: suspend: handle EINTR
Date: Wed, 18 Apr 2012 16:30:49 -0300

The read() call in bios_supports_mode() can fail with EINTR if a child
terminates during the call. Handle it.

Signed-off-by: Luiz Capitulino <address@hidden>
---
 qga/commands-posix.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 41ba0c5..4d8c067 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -621,10 +621,14 @@ static void bios_supports_mode(const char *pmutils_bin, 
const char *pmutils_arg,
         goto out;
     }
 
-    ret = read(pipefds[0], &status, sizeof(status));
-    if (ret == sizeof(status) && WIFEXITED(status) &&
-        WEXITSTATUS(status) == SUSPEND_SUPPORTED) {
-            goto out;
+    while (true) {
+        ret = read(pipefds[0], &status, sizeof(status));
+        if (ret == sizeof(status) && WIFEXITED(status) &&
+            WEXITSTATUS(status) == SUSPEND_SUPPORTED) {
+                goto out;
+        } else if (ret == -1 && errno != EINTR) {
+            break;
+        }
     }
 
     error_set(err, QERR_UNSUPPORTED);
-- 
1.7.9.2.384.g4a92a




reply via email to

[Prev in Thread] Current Thread [Next in Thread]