]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mworker: only write to pidfile if it exists
authorWilly Tarreau <w@1wt.eu>
Tue, 23 Jan 2018 18:20:19 +0000 (19:20 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 23 Jan 2018 18:20:19 +0000 (19:20 +0100)
A missing test causes a write(-1, $PID) to appear in strace output when
in master-worker mode. This is totally harmless though.

This fix must be backported to 1.8.

src/haproxy.c

index 89044c6a5d33f7ca16e392b333e0bde2d61c2a4c..8e0e30d8a4088459a96aecfb7baa650bd55d8572 100644 (file)
@@ -2786,7 +2786,8 @@ int main(int argc, char **argv)
                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)));
+                       if (pidfd >= 0)
+                               shut_your_big_mouth_gcc(write(pidfd, pidstr, strlen(pidstr)));
                }
 
                /* the father launches the required number of processes */