qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Raphael Pour <raphael.pour@hetzner.com>, qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org
Subject: Re: [PATCH] qemu-nbd: Close inherited stderr
Date: Tue, 12 May 2020 08:57:15 -0500	[thread overview]
Message-ID: <26f7bcad-d058-712e-1663-21923da40f0f@redhat.com> (raw)
In-Reply-To: <ac17fad1-baf1-75ad-843d-cab8d17f1b2e@hetzner.com>

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.pour@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.pour@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



  reply	other threads:[~2020-05-12 13:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-12  8:56 [PATCH] qemu-nbd: Close inherited stderr Raphael Pour
2020-05-12 13:57 ` Eric Blake [this message]
2020-05-13  7:14 ` Raphael Pour
2020-05-13 13:02   ` Eric Blake
2020-05-14  5:33   ` Raphael Pour

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=26f7bcad-d058-712e-1663-21923da40f0f@redhat.com \
    --to=eblake@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=raphael.pour@hetzner.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).