aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2015-02-25 13:08:22 -0500
committerPaolo Bonzini <pbonzini@redhat.com>2015-03-18 12:06:54 +0100
commit70d4739ef200760d8cac3355d05b4252f2f37fec (patch)
tree6ae717df16c368940f4d3df4ebd6d689704d1e74
parent98f44bbe70bb803e7be2421b7cc92a1c179afb87 (diff)
qemu-nbd: fork() can fail
It is very unlikely, but it is possible. Signed-off-by: Max Reitz <mreitz@redhat.com> Message-Id: <1424887718-10800-10-git-send-email-mreitz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--qemu-nbd.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 0cb0e4e29a..0c9e807a1a 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);