From deed780a22d61e3c34f426f492f5735ac45109c1 Mon Sep 17 00:00:00 2001 From: William Lallemand Date: Mon, 6 Nov 2017 11:00:04 +0100 Subject: [PATCH] MINOR: mworker: write parent pid in the pidfile The first pid in the pidfile is now the parent, it's more convenient for supervising the processus. You can now reload haproxy in master-worker mode with convenient command like: kill -USR2 $(head -1 /tmp/haproxy.pid) --- src/haproxy.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/haproxy.c b/src/haproxy.c index f12e903b2..bcbbad4a1 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -2631,6 +2631,13 @@ int main(int argc, char **argv) } } + /* if in master-worker mode, write the PID of the father */ + if (global.mode & MODE_MWORKER) { + char pidstr[100]; + snprintf(pidstr, sizeof(pidstr), "%d\n", getpid()); + shut_your_big_mouth_gcc(write(pidfd, pidstr, strlen(pidstr))); + } + /* the father launches the required number of processes */ for (proc = 0; proc < global.nbproc; proc++) { ret = fork();