mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 06:11:32 +02:00
MEDIUM: init: support more command line arguments after pid list
Given that all command line arguments start with a '-' and that no pid number can start with this character, there's no constraint to make the pid list the last argument. Let's relax this rule.
This commit is contained in:
parent
0078bfcb43
commit
c6ca1aa34d
@ -445,7 +445,7 @@ void usage(char *name)
|
|||||||
" -dG disables getaddrinfo() usage\n"
|
" -dG disables getaddrinfo() usage\n"
|
||||||
#endif
|
#endif
|
||||||
" -dV disables SSL verify on servers side\n"
|
" -dV disables SSL verify on servers side\n"
|
||||||
" -sf/-st [pid ]* finishes/terminates old pids. Must be last arguments.\n"
|
" -sf/-st [pid ]* finishes/terminates old pids.\n"
|
||||||
"\n",
|
"\n",
|
||||||
name, DEFAULT_MAXCONN, cfg_maxpconn);
|
name, DEFAULT_MAXCONN, cfg_maxpconn);
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -688,19 +688,20 @@ void init(int argc, char **argv)
|
|||||||
oldpids_sig = SIGUSR1; /* finish then exit */
|
oldpids_sig = SIGUSR1; /* finish then exit */
|
||||||
else
|
else
|
||||||
oldpids_sig = SIGTERM; /* terminate immediately */
|
oldpids_sig = SIGTERM; /* terminate immediately */
|
||||||
argv++; argc--;
|
|
||||||
|
|
||||||
if (argc > 0) {
|
while (argc > 1 && argv[1][0] != '-') {
|
||||||
oldpids = calloc(argc, sizeof(int));
|
oldpids = realloc(oldpids, (nb_oldpids + 1) * sizeof(int));
|
||||||
while (argc > 0) {
|
if (!oldpids) {
|
||||||
|
Alert("Cannot allocate old pid : out of memory.\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
argc--; argv++;
|
||||||
oldpids[nb_oldpids] = atol(*argv);
|
oldpids[nb_oldpids] = atol(*argv);
|
||||||
if (oldpids[nb_oldpids] <= 0)
|
if (oldpids[nb_oldpids] <= 0)
|
||||||
usage(progname);
|
usage(progname);
|
||||||
argc--; argv++;
|
|
||||||
nb_oldpids++;
|
nb_oldpids++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else { /* >=2 args */
|
else { /* >=2 args */
|
||||||
argv++; argc--;
|
argv++; argc--;
|
||||||
if (argc == 0)
|
if (argc == 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user