From 00b57391dd27d15fa25d5577b7c0192802468bab Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 23 Apr 2021 16:35:02 +0200 Subject: [PATCH] lib: Directly call close_low_fd() in become_daemon() Signed-off-by: Volker Lendecke Reviewed-by: Andreas Schneider --- lib/util/become_daemon.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/util/become_daemon.c b/lib/util/become_daemon.c index 800a57437cc..f89ca7f27cf 100644 --- a/lib/util/become_daemon.c +++ b/lib/util/become_daemon.c @@ -115,7 +115,18 @@ void become_daemon(bool do_fork, bool no_session, bool log_stdout) /* stdin must be open if we do not fork, for monitoring for * close. stdout must be open if we are logging there, and we * never close stderr (but debug might dup it onto a log file) */ - close_low_fds(do_fork, !log_stdout, false); + if (do_fork) { + int ret = close_low_fd(0); + if (ret != 0) { + exit_daemon("close_low_fd(0) failed: %s\n", errno); + } + } + if (!log_stdout) { + int ret = close_low_fd(1); + if (ret != 0) { + exit_daemon("close_low_fd(1) failed: %s\n", errno); + } + } } void exit_daemon(const char *msg, int error) -- 2.11.4.GIT