Commit e6df58a5 authored by Max Reitz's avatar Max Reitz Committed by Eric Blake
Browse files

qemu-nbd: Do not close stderr



We kept old_stderr specifically so we could keep emitting error message
on stderr.  However, qemu_daemon() closes stderr.  Therefore, we need to
dup() stderr to old_stderr before invoking qemu_daemon().

Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
Message-Id: <20190508211820.17851-4-mreitz@redhat.com>
Signed-off-by: default avatarEric Blake <eblake@redhat.com>
parent 6177b584
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1004,10 +1004,11 @@ int main(int argc, char **argv)
            exit(EXIT_FAILURE);
        } else if (pid == 0) {
            close(stderr_fd[0]);

            old_stderr = dup(STDERR_FILENO);
            ret = qemu_daemon(1, 0);

            /* Temporarily redirect stderr to the parent's pipe...  */
            old_stderr = dup(STDERR_FILENO);
            dup2(stderr_fd[1], STDERR_FILENO);
            if (ret < 0) {
                error_report("Failed to daemonize: %s", strerror(errno));