aboutgitcodebugslistschat
path: root/passt.c
diff options
context:
space:
mode:
Diffstat (limited to 'passt.c')
-rw-r--r--passt.c6
1 files 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;
}