From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDDF7C433E2 for ; Thu, 14 May 2020 06:36:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C89EA205CB for ; Thu, 14 May 2020 06:36:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C89EA205CB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hetzner.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZ7TX-0002MC-Ue for qemu-devel@archiver.kernel.org; Thu, 14 May 2020 02:36:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZ7PM-0004lf-VK; Thu, 14 May 2020 02:31:52 -0400 Received: from mail.hetzner.company ([2a01:4f8:d0a:203a::1]:50232) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZ7PL-0001SJ-LG; Thu, 14 May 2020 02:31:52 -0400 Received: from [2a01:4f8:0:a53b:fd81:523d:dd49:b8d4] (helo=hetzner.com) by mail.hetzner.company with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1jZ7PI-0000UC-Qo; Thu, 14 May 2020 08:31:48 +0200 From: Raphael Pour To: Eric Blake Subject: [PATCH v2 1/1] qemu-nbd: Close inherited stderr Date: Thu, 14 May 2020 08:31:12 +0200 Message-Id: <20200514063112.1457125-2-raphael.pour@hetzner.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200514063112.1457125-1-raphael.pour@hetzner.com> References: <1jYr2L-0004mc-Jj@mail.hetzner.company> <20200514063112.1457125-1-raphael.pour@hetzner.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Authenticated-Sender: raphael.pour@hetzner.com Received-SPF: pass client-ip=2a01:4f8:d0a:203a::1; envelope-from=raphael.pour@hetzner.com; helo=mail.hetzner.company X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Raphael Pour , qemu-devel@nongnu.org, qemu-block@nongnu.org, qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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(-) diff --git a/qemu-nbd.c b/qemu-nbd.c index 4aa005004e..a324d21c5e 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -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... */ -- 2.25.4