BUG/MEDIUM: startup: report status if daemonized process fails
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Mon, 9 Dec 2024 17:51:34 +0000 (18:51 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 10 Dec 2024 10:09:53 +0000 (11:09 +0100)
commit36cbc7e536e265da8f45e230739fca635760512e
tree90a7077873e858655a8911f5258893f8a21f0641
parentc13ef1d973e96f1bdba3c93252473ab6ba12fee8
BUG/MEDIUM: startup: report status if daemonized process fails

Due to master-worker rework, daemonization fork happens now before parsing
and applying the configuration. This makes impossible to report correctly all
warnings and alerts to shell's stdout. Daemonzied process fails, while being
already in background, exit code reported by shell via '$?' equals to 0, as
it's the exit code of his parent.

To fix this, let's create a pipe between parent and daemonized child. The
child will send into this pipe a "READY" message, when it finishes his
initialization. The parent will wait on the "read" end of the pipe until
receiving something. If read() fails, parent obtains the status of the
exited child with waitpid(). So, the parent can correctly report the error to
the stdout and he can exit with child's exitcode.

This fix should be backported only in 3.1.

(cherry picked from commit 663d75e7a00a9c50185cca322cbc64de934b6631)
Signed-off-by: Willy Tarreau <w@1wt.eu>
include/haproxy/global.h
src/haproxy.c