[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] qemu-nbd: Close inherited stderr
From: |
Raphael Pour |
Subject: |
[PATCH] qemu-nbd: Close inherited stderr |
Date: |
Tue, 12 May 2020 10:56:55 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 |
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" <address@hidden>
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 <address@hidden>
---
qemu-nbd.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 108a51f7e..f2981e18a 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -1032,8 +1032,15 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
- /* ... close the descriptor we inherited and go on. */
+ /* ... close the descriptor we inherited and ... */
close(stderr_fd[1]);
+
+ /* ... also close the old_stderr IF fork_process is false
otherwise
+ * it will never get closed.
+ */
+ if (!fork_process) {
+ close(old_stderr);
+ }
} else {
bool errors = false;
char *buf;
--
2.25.4
--
Hetzner Online GmbH
Am Datacenter-Park 1
08223 Falkenstein/Vogtland
address@hidden
www.hetzner.com
Registergericht Ansbach, HRB 6089
Geschäftsführer: Martin Hetzner, Stephan Konvickova, Günther Müller
signature.asc
Description: OpenPGP digital signature
- [PATCH] qemu-nbd: Close inherited stderr,
Raphael Pour <=