From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202606 header.b=XaTBQE6V; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 2A2B55A0623 for ; Tue, 14 Jul 2026 11:29:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202606; t=1784021370; bh=84Lei9zQzx0snQRy6JOT6FJ8/zJD/bl18xutcfXNmps=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XaTBQE6VqFC7O2WGicP7RUdqqFYD1Eeh2ifN6pxuFpykzvaRXQB3yv5ZzrshVLO6n aa0w/1nzXgWuu3nvqUo/q57Yq6ZeTzNBvnXzr27x05mDl0lmv0/6aNYRiBoQliruAw XdrVssFlQe4v7M6ep6amQ7EAR/DIZIZzJSGd8RSumcuoY1m6e6BUG6LPGbG0rawCBu 2Nid+pYPbS20s7h3nIzoxj9t4dFx1o9Y5eJQlkq6AFdPe9HKDZmvm0OUUYObCOi3+D z/1FTBZrensStoOx5/AVexsNQUEb82G1WrjfskaRlP2CIEE3f70mwsiNLHAue4iwwR ctHTVkiQ3dITg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4gzvCG03Rkz4wCH; Tue, 14 Jul 2026 19:29:29 +1000 (AEST) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 6/6] passt: *Always* close pidfile_fd, not just when daemonizing Date: Tue, 14 Jul 2026 19:29:26 +1000 Message-ID: <20260714092926.2881848-7-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260714092926.2881848-1-david@gibson.dropbear.id.au> References: <20260714092926.2881848-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 4LYRHAAUTQNZ4RZ4YSQ2OCPKUPPK7PII X-Message-ID-Hash: 4LYRHAAUTQNZ4RZ4YSQ2OCPKUPPK7PII X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: In order to satisfy static checkers that we don't have an fd leak, a9c61ffaf153 added a close() of c->pidfile_fd, amongst others. However, it only close()s it in the case where we daemonize into the background. While less universally useful in the foreground / non-daemon case, it's perfectly reasonable to still have a pidfile. We'll still write it, and we should still close it. Fixes: a9c61ffaf153 ("util, passt: Close daemon-lifetime fds on exit to avoid Coverity warning") Signed-off-by: David Gibson --- passt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/passt.c b/passt.c index 663a1005..4b7c8434 100644 --- a/passt.c +++ b/passt.c @@ -424,14 +424,14 @@ int main(int argc, char **argv) if (!c->foreground) { __daemon(c->pidfile_fd, devnull_fd); - close(c->pidfile_fd); - c->pidfile_fd = -1; log_stderr = false; } else { pidfile_write(c->pidfile_fd, getpid()); - c->pidfile_fd = -1; } + close(c->pidfile_fd); + c->pidfile_fd = -1; + if (devnull_fd > STDERR_FILENO) close(devnull_fd); -- 2.55.0