Skip to content

Commit

Permalink
qemu-nbd: fork() can fail
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
XanClic authored and bonzini committed Mar 18, 2015
1 parent 98f44bb commit 70d4739
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion qemu-nbd.c
Expand Up @@ -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);

Expand Down

0 comments on commit 70d4739

Please sign in to comment.