From b0ca29ed09e9f6e33408b7207eaf4dec9a650e89 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Fri, 17 Jul 2026 15:46:29 +1000 Subject: passt: Always close pidfile_fd, not just when daemonizing 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 Signed-off-by: Stefano Brivio --- passt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/passt.c b/passt.c index 4e5b928..e922bd8 100644 --- a/passt.c +++ b/passt.c @@ -423,11 +423,13 @@ 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()); + } + + if (c->pidfile_fd >= 0) { + close(c->pidfile_fd); c->pidfile_fd = -1; } -- cgit v1.2.3