On 5/12/20 3:56 AM, Raphael Pour wrote:
Hello,
after e6df58a5, the inherited stderr 'old_stderr' won't get closed
anymore if 'fork_process' is false. This causes other processes relying
on EOF to infinitely block or crash.
From 47ab9b517038d13117876a8bb3ef45c53d7f2f9e Mon Sep 17 00:00:00 2001
From: "Raphael Pour" <raphael.p...@hetzner.com>
Date: Tue, 12 May 2020 10:18:44 +0200
Subject: [PATCH] qemu-nbd: Close inherited stderr
Close inherited stderr of the parent if fork_process is false.
Otherwise no one will close it. (introduced by e6df58a5)
Signed-off-by: Raphael Pour <raphael.p...@hetzner.com>
---
qemu-nbd.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
Wouldn't it just be simpler to not dup in the first place?
diff --git i/qemu-nbd.c w/qemu-nbd.c
index 4aa005004ebd..6ba2544feb3a 100644
--- i/qemu-nbd.c
+++ w/qemu-nbd.c
@@ -916,7 +916,9 @@ int main(int argc, char **argv)
} else if (pid == 0) {
close(stderr_fd[0]);
- old_stderr = dup(STDERR_FILENO);
+ if (fork_process) {
+ old_stderr = dup(STDERR_FILENO);
+ }
ret = qemu_daemon(1, 0);
/* Temporarily redirect stderr to the parent's pipe... */
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org