]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: init: make sure only daemonized processes change their session
authorWilly Tarreau <w@1wt.eu>
Wed, 4 Dec 2024 07:26:24 +0000 (08:26 +0100)
committerWilliam Lallemand <wlallemand@haproxy.com>
Wed, 4 Dec 2024 18:46:42 +0000 (19:46 +0100)
Commit 8dd4efe42f ("MAJOR: mworker: move master-worker fork in init()")
introduced some sensitive changes to the startup code (which was
expected), and one sensitive change is that the second call to setsid()
was accidentally made unconditional. As such it even applies to foreground
processes, resulting in foreground processes being detached from the
terminal and no longer responding to Ctrl-C nor Ctrl-Z. An example of
this simply consists in start haproxy -db under sudo. Then a new shell
is required to stop it.

This patch removes this second setsid(), as it is already done in
apply_daemon_mode().

This must be backported to 3.1.

src/haproxy.c

index 1efa4a8b3c7bf8111c2f41f0664dca671c721d5d..c3538748c65acc87aae8f025a2e38400529ca8ce 100644 (file)
@@ -3603,7 +3603,6 @@ int main(int argc, char **argv)
                devnullfd = -1;
        }
        pid = getpid(); /* update pid */
-       setsid();
        fork_poller();
 
        /* pass through every cli socket, and check if it's bound to