#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) {
execv(argv[0], argv);
exit(0);
}
- return pid;
}
static int read_pids(char ***pid_strv)
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]);
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;
}