]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: startup: close devnullfd, when daemon mode is applied
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Wed, 16 Oct 2024 09:22:00 +0000 (11:22 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 16 Oct 2024 20:02:39 +0000 (22:02 +0200)
commitc42ad79134a08dca04a98c6016484785c054cb23
tree97ef036b2bc1e9a70758356ff74a6ef591559466
parentdc53c372349f30ff4fb9618e6bb131a0a8285855
MINOR: startup: close devnullfd, when daemon mode is applied

In case of daemon mode now daemonization fork happens in the early init stage
before parsing and applying the configuration, so we can't close
stdio/stderr/stdout immediately after forking. We keep it open until the most
of configuration, including chroot are applied in order to show alerts, if
there are some problems. To achieve this /dev/null is opened just before calling
chroot(), and after the chroot block it's used to close all standard outputs
and stdin. At this point we no longer need the fd of /dev/null, so we can close
it as well.
src/haproxy.c