diff options
| author | Max Reitz <mreitz@redhat.com> | 2019-05-08 23:18:18 +0200 |
|---|---|---|
| committer | Eric Blake <eblake@redhat.com> | 2019-06-13 08:50:47 -0500 |
| commit | e6df58a5578fee7a50bbf36f4a50a2781cff855d (patch) | |
| tree | 3d22201a770ced994c2f720fdf0d0003321e9447 | |
| parent | 6177b58431cd19fddfd025225403876b8deeeec7 (diff) | |
| download | focaccia-qemu-e6df58a5578fee7a50bbf36f4a50a2781cff855d.tar.gz focaccia-qemu-e6df58a5578fee7a50bbf36f4a50a2781cff855d.zip | |
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: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20190508211820.17851-4-mreitz@redhat.com> Signed-off-by: Eric Blake <eblake@redhat.com>
| -rw-r--r-- | qemu-nbd.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/qemu-nbd.c b/qemu-nbd.c index 99377a3f14..a8cb39e510 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -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)); |