forked from pool/haproxy
0b429848d7
Update to 1.4.25. Amended SR with missing patch information in .changes OBS-URL: https://build.opensuse.org/request/show/232846 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/haproxy?expand=0&rev=4
66 lines
1.8 KiB
Diff
66 lines
1.8 KiB
Diff
From f0eb767ac292c24ed37e5cec2a9a86d773df75d0 Mon Sep 17 00:00:00 2001
|
|
From: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
|
|
Date: Fri, 22 Nov 2013 08:36:01 +0100
|
|
Subject: [PATCH 04/15] BUG/MEDIUM: systemd-wrapper: don't leak zombie
|
|
processes
|
|
|
|
Formerly, if A was replaced by B, and then B by C before
|
|
A finished exiting, we didn't wait for B to finish so it
|
|
ended up as a zombie process.
|
|
Fix this by waiting randomly every child we spawn.
|
|
|
|
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
|
|
---
|
|
src/haproxy-systemd-wrapper.c | 10 ++++------
|
|
1 file changed, 4 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/src/haproxy-systemd-wrapper.c b/src/haproxy-systemd-wrapper.c
|
|
index 596801591b9e..8499b35188c5 100644
|
|
--- a/src/haproxy-systemd-wrapper.c
|
|
+++ b/src/haproxy-systemd-wrapper.c
|
|
@@ -19,12 +19,11 @@
|
|
#include <unistd.h>
|
|
#include <sys/wait.h>
|
|
|
|
-static pid_t pid = 0;
|
|
static char *pid_file = "/run/haproxy.pid";
|
|
static int main_argc;
|
|
static char **main_argv;
|
|
|
|
-static pid_t spawn_haproxy(char **pid_strv, int nb_pid)
|
|
+static void spawn_haproxy(char **pid_strv, int nb_pid)
|
|
{
|
|
pid_t pid = fork();
|
|
if (!pid) {
|
|
@@ -45,7 +44,6 @@ static pid_t spawn_haproxy(char **pid_strv, int nb_pid)
|
|
execv(argv[0], argv);
|
|
exit(0);
|
|
}
|
|
- return pid;
|
|
}
|
|
|
|
static int read_pids(char ***pid_strv)
|
|
@@ -77,7 +75,7 @@ static void signal_handler(int signum __attribute__((unused)))
|
|
char **pid_strv = NULL;
|
|
int nb_pid = read_pids(&pid_strv);
|
|
|
|
- pid = spawn_haproxy(pid_strv, nb_pid);
|
|
+ spawn_haproxy(pid_strv, nb_pid);
|
|
|
|
for (i = 0; i < nb_pid; ++i)
|
|
free(pid_strv[i]);
|
|
@@ -107,8 +105,8 @@ int main(int argc, char **argv)
|
|
|
|
signal(SIGUSR2, &signal_handler);
|
|
|
|
- pid = spawn_haproxy(NULL, 0);
|
|
- while (-1 != waitpid(pid, NULL, 0) || errno == EINTR);
|
|
+ spawn_haproxy(NULL, 0);
|
|
+ while (-1 != wait(NULL) || errno == EINTR);
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|
|
--
|
|
1.8.4.5
|
|
|