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