From: Willy Tarreau Date: Wed, 4 Dec 2024 07:26:24 +0000 (+0100) Subject: BUG/MEDIUM: init: make sure only daemonized processes change their session X-Git-Tag: v3.2-dev1~50 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=70e4938aec671c5bd1d69fee4ca1c8eea9f72bd3;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: init: make sure only daemonized processes change their session 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. --- diff --git a/src/haproxy.c b/src/haproxy.c index 1efa4a8b3c..c3538748c6 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -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