]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mworker: write parent pid in the pidfile
authorWilliam Lallemand <wlallemand@haproxy.com>
Mon, 6 Nov 2017 10:00:04 +0000 (11:00 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 6 Nov 2017 10:08:38 +0000 (11:08 +0100)
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

index f12e903b286f8bf07f6428ae0fb049e9bc4bcb5f..bcbbad4a115e7b5ae21a7991f8c0cb7ee2a15159 100644 (file)
@@ -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();