From 3bc0a399d2875e9e0627a70906c1403eef60ec60 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 25 Oct 2016 16:51:40 +0200 Subject: [PATCH 15/26] MINOR: systemd: report it when execve() fails It's important to know that a signal sent to the wrapper had no effect because something failed during execve(). Ideally more info (strerror) should be reported. It would be nice to backport this to 1.6 and 1.5. (cherry picked from commit a785269b4e09114224062081f02b443b6008c524) --- src/haproxy-systemd-wrapper.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/haproxy-systemd-wrapper.c b/src/haproxy-systemd-wrapper.c index 15c48ca..f4fcab1 100644 --- a/src/haproxy-systemd-wrapper.c +++ b/src/haproxy-systemd-wrapper.c @@ -107,8 +107,12 @@ static void spawn_haproxy(char **pid_strv, int nb_pid) fprintf(stderr, "\n"); execv(argv[0], argv); + fprintf(stderr, SD_NOTICE "haproxy-systemd-wrapper: execv(%s) failed, please try again later.\n", argv[0]); exit(1); } + else if (pid == -1) { + fprintf(stderr, SD_NOTICE "haproxy-systemd-wrapper: failed to fork(), please try again later.\n"); + } } static int read_pids(char ***pid_strv) @@ -180,6 +184,7 @@ static void do_restart(int sig) execv(wrapper_argv[0], wrapper_argv); /* failed, let's reinstall the signal handler and continue */ setup_signal_handler(); + fprintf(stderr, SD_NOTICE "haproxy-systemd-wrapper: re-exec(%s) failed.\n", wrapper_argv[0]); } /* handles SIGTERM and SIGINT only */ -- 2.7.3