qemu-nbd: Close inherited stderr
A message that is not in the archive (sent off-list or not yet received): [email protected]
v2 cover qemu-nbd: Close inherited stderr
Hello,
introduced with e6df58a5, stderr won't get closed if the fork option is set. This causes other processes reading stderr to block infinietly or crash while relying on EOF.
v2:
- Instead of closing the inherited stderr in the child, avoid the dup in the parent if the fork option is not set.
Raphael Pour (1):
qemu-nbd: Close inherited stderr
qemu-nbd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Signature · 1 line
2.25.4
PATCH v2 1/1 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)
--- qemu-nbd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
qemu-nbd.c +7 -1
@@ -916,7 +916,13 @@ int main(int argc, char **argv) }else if (pid ==0 ) {close (stderr_fd[0 ]); - old_stderr =dup (STDERR_FILENO ); +/* Remember parents stderr only if the fork option is set. +* The child won't close this inherited fd otherwise. +*/ +if (fork_process) { + old_stderr =dup (STDERR_FILENO ); + } + ret =qemu_daemon (1 ,0 );/* Temporarily redirect stderr to the parent's pipe... */
Signature · 1 line
2.25.4
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Message-id: [email protected]
Subject: [PATCH v2 0/1] qemu-nbd: Close inherited stderr
Type: series
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
76bb928 qemu-nbd: Close inherited stderr
=== OUTPUT BEGIN ===
WARNING: Block comments use a leading /* on a separate line #20: FILE: qemu-nbd.c:919:
+ /* Remember parents stderr only if the fork option is set.
ERROR: suspect code indent for conditional statements (12, 14) #23: FILE: qemu-nbd.c:922:
+ if (fork_process) {
+ old_stderr = dup(STDERR_FILENO);
ERROR: Missing Signed-off-by: line(s)
total: 2 errors, 1 warnings, 14 lines checked
Commit 76bb928d8364 (qemu-nbd: Close inherited stderr) has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Quoted 25 lines · On 5/14/20 7:51 AM, [email protected] wrote:
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Message-id: [email protected]
Subject: [PATCH v2 0/1] qemu-nbd: Close inherited stderr
Type: series=== OUTPUT BEGIN ===
WARNING: Block comments use a leading /* on a separate line #20: FILE: qemu-nbd.c:919:
+ /* Remember parents stderr only if the fork option is set.ERROR: suspect code indent for conditional statements (12, 14) #23: FILE: qemu-nbd.c:922:
(quoted diff) +2
-0+ if (fork_process) { + old_stderr = dup(STDERR_FILENO);
Quoted 1 line
ERROR: Missing Signed-off-by: line(s)
Patchew is correct. All three things should be fixed (the missing S-o-b is most important - I can't supply that; the missing spaces and comment formatting are something I could touch up).
The comment could use some grammar help (s/parents/parent's/), and in truth, I don't think it adds much beyond what the code itself is already doing, so rather than adding another line to silence patchew, you could instead just eliminate the comment and life would still be fine. Or if you want a one-line comment, I might suggest:
/* Remember parent's stderr if we will restoring it. */
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Quoted 8 lines · Eric Blake
Quoted 4 lines
WARNING: Block comments use a leading /* on a separate line #20: FILE: qemu-nbd.c:919:
+ /* Remember parents stderr only if the fork option is set.The comment could use some grammar help (s/parents/parent's/), and in truth, I don't think it adds much beyond what the code itself is already doing, so rather than adding another line to silence patchew, you could instead just eliminate the comment and life would still be fine. Or if you want a one-line comment, I might suggest:
/* Remember parent's stderr if we will restoring it. */
It helps if I don't hit 'send' too early.
/* Remember parent's stderr if we will be restoring it. */
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Quoted 13 lines · Eric Blake
Quoted 11 lines · Eric Blake
Quoted 4 lines
WARNING: Block comments use a leading /* on a separate line #20: FILE: qemu-nbd.c:919:
+ /* Remember parents stderr only if the fork option is set.The comment could use some grammar help (s/parents/parent's/), and in truth, I don't think it adds much beyond what the code itself is already doing, so rather than adding another line to silence patchew, you could instead just eliminate the comment and life would still be fine. Or if you want a one-line comment, I might suggest:
Quoted 6 lines
Quoted 1 line
/* Remember parent's stderr if we will restoring it. */
It helps if I don't hit 'send' too early.
/* Remember parent's stderr if we will be restoring it. */
From e5749541494abcdcaa37d752172741e1bc38e984 Mon Sep 17 00:00:00 2001
From: Raphael Pour <[email protected]>
Date: Fri, 15 May 2020 08:30:50 +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)
--- qemu-nbd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
qemu-nbd.c +5 -1
@@ -916,7 +916,11 @@ int main(int argc, char **argv) }else if (pid ==0 ) {close (stderr_fd[0 ]); - old_stderr =dup (STDERR_FILENO ); +/* Remember parent's stderr if we will be restoring it. */ +if (fork_process) { + old_stderr =dup (STDERR_FILENO ); + } + ret =qemu_daemon (1 ,0 );/* Temporarily redirect stderr to the parent's pipe... */
Signature · 16 lines
2.25.4 I fixed the issues and checkpatch gave me a 'ready for submission'. Is this the right way to submit a fixed patch or should it be a v3? -- Hetzner Online GmbH Am Datacenter-Park 1 08223 Falkenstein/Vogtland [email protected] www.hetzner.com Registergericht Ansbach, HRB 6089 Geschäftsführer: Martin Hetzner, Stephan Konvickova, Günther Müller
Eric Blake
Reviewed-byQuoted 5 lines · Raphael Pour
Quoted 1 line
From
e5749541494abcdcaa37d752172741e1bc38e984Mon Sep 17 00:00:00 2001From: Raphael Pour <[email protected]>
Date: Fri, 15 May 2020 08:30:50 +0200
Subject: [PATCH] qemu-nbd: Close inherited stderr
Quoted 7 lines
Close inherited stderr of the parent if
fork_processis false. Otherwise no one will close it. (introduced bye6df58a5)Signed-off-by Raphael Pour <[email protected]>--- qemu-nbd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Thanks. It might have been easier posting this as a standalone v3 rather than buried in reply to v2, but I have now queued it to go in through my NBD tree (I plan on doing a pull request Monday).
I've also taken the liberty to amend the commit message as follows, to give more context into why the fix is needed:
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)
This only affected 'qemu-nbd -c /dev/nbd0'.
Message-Id: <[email protected]>
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
[...] introduced with e6df58a5, stderr won't get closed if the fork option is __not__ set.
Quoted 2 lines · Raphael Pour
introduced with
e6df58a5, stderr won't get closed if the fork option is set.
Signature · 8 lines
Hetzner Online GmbH Am Datacenter-Park 1 08223 Falkenstein/Vogtland [email protected] www.hetzner.com Registergericht Ansbach, HRB 6089 Geschäftsführer: Martin Hetzner, Stephan Konvickova, Günther Müller