diff options
| author | David Gibson <david@gibson.dropbear.id.au> | 2026-07-17 15:46:29 +1000 |
|---|---|---|
| committer | Stefano Brivio <sbrivio@redhat.com> | 2026-07-18 09:53:47 +0200 |
| commit | b0ca29ed09e9f6e33408b7207eaf4dec9a650e89 (patch) | |
| tree | 4a2bb170efc3d8a6f0e1e90eab601a7e45f5456f | |
| parent | 5418bd9a06c71f5c8e47a71aa460baf6d2a4f32e (diff) | |
| download | passt-b0ca29ed09e9f6e33408b7207eaf4dec9a650e89.tar passt-b0ca29ed09e9f6e33408b7207eaf4dec9a650e89.tar.gz passt-b0ca29ed09e9f6e33408b7207eaf4dec9a650e89.tar.bz2 passt-b0ca29ed09e9f6e33408b7207eaf4dec9a650e89.tar.lz passt-b0ca29ed09e9f6e33408b7207eaf4dec9a650e89.tar.xz passt-b0ca29ed09e9f6e33408b7207eaf4dec9a650e89.tar.zst passt-b0ca29ed09e9f6e33408b7207eaf4dec9a650e89.zip | |
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 <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
| -rw-r--r-- | passt.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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; } |
