qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PULL 07/19] qemu-nbd: fork() can fail


From: Paolo Bonzini
Subject: [Qemu-devel] [PULL 07/19] qemu-nbd: fork() can fail
Date: Wed, 18 Mar 2015 12:24:54 +0100

From: Max Reitz <address@hidden>

It is very unlikely, but it is possible.

Signed-off-by: Max Reitz <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
 qemu-nbd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/qemu-nbd.c b/qemu-nbd.c
index 0cb0e4e..0c9e807 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -635,7 +635,9 @@ int main(int argc, char **argv)
          * print errors and exit with the proper status code.
          */
         pid = fork();
-        if (pid == 0) {
+        if (pid < 0) {
+            err(EXIT_FAILURE, "Failed to fork");
+        } else if (pid == 0) {
             close(stderr_fd[0]);
             ret = qemu_daemon(1, 0);
 
-- 
2.3.0





reply via email to

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