First Commit
[librecmc/package-feed.git] / net / haproxy / patches / 0015-MINOR-systemd-report-it-when-execve-fails.patch
1 From 3bc0a399d2875e9e0627a70906c1403eef60ec60 Mon Sep 17 00:00:00 2001
2 From: Willy Tarreau <w@1wt.eu>
3 Date: Tue, 25 Oct 2016 16:51:40 +0200
4 Subject: [PATCH 15/26] MINOR: systemd: report it when execve() fails
5
6 It's important to know that a signal sent to the wrapper had no effect
7 because something failed during execve(). Ideally more info (strerror)
8 should be reported. It would be nice to backport this to 1.6 and 1.5.
9 (cherry picked from commit a785269b4e09114224062081f02b443b6008c524)
10 ---
11  src/haproxy-systemd-wrapper.c | 5 +++++
12  1 file changed, 5 insertions(+)
13
14 diff --git a/src/haproxy-systemd-wrapper.c b/src/haproxy-systemd-wrapper.c
15 index 15c48ca..f4fcab1 100644
16 --- a/src/haproxy-systemd-wrapper.c
17 +++ b/src/haproxy-systemd-wrapper.c
18 @@ -107,8 +107,12 @@ static void spawn_haproxy(char **pid_strv, int nb_pid)
19                 fprintf(stderr, "\n");
20  
21                 execv(argv[0], argv);
22 +               fprintf(stderr, SD_NOTICE "haproxy-systemd-wrapper: execv(%s) failed, please try again later.\n", argv[0]);
23                 exit(1);
24         }
25 +       else if (pid == -1) {
26 +               fprintf(stderr, SD_NOTICE "haproxy-systemd-wrapper: failed to fork(), please try again later.\n");
27 +       }
28  }
29  
30  static int read_pids(char ***pid_strv)
31 @@ -180,6 +184,7 @@ static void do_restart(int sig)
32         execv(wrapper_argv[0], wrapper_argv);
33         /* failed, let's reinstall the signal handler and continue */
34         setup_signal_handler();
35 +       fprintf(stderr, SD_NOTICE "haproxy-systemd-wrapper: re-exec(%s) failed.\n", wrapper_argv[0]);
36  }
37  
38  /* handles SIGTERM and SIGINT only */
39 -- 
40 2.7.3
41