Parse retry schedule correctly, #129. Thanks to vaeth.

This commit is contained in:
Roy Marples 2008-12-28 14:05:33 +00:00
parent 438665357b
commit f4b8366942

View File

@ -626,6 +626,7 @@ int start_stop_daemon(int argc, char **argv)
char *startas = NULL; char *startas = NULL;
char *name = NULL; char *name = NULL;
char *pidfile = NULL; char *pidfile = NULL;
char *retry = NULL;
int sig = 0; int sig = 0;
int nicelevel = 0; int nicelevel = 0;
bool background = false; bool background = false;
@ -694,7 +695,7 @@ int start_stop_daemon(int argc, char **argv)
break; break;
case 'R': /* --retry <schedule>|<timeout> */ case 'R': /* --retry <schedule>|<timeout> */
parse_schedule(optarg, sig); retry = optarg;
break; break;
case 'S': /* --start */ case 'S': /* --start */
@ -853,7 +854,9 @@ int start_stop_daemon(int argc, char **argv)
else if (exec) else if (exec)
*--argv = exec; *--argv = exec;
if (stop || sig) { if (stop || sig != 0) {
if (sig == 0)
sig = SIGTERM;
if (!*argv && !pidfile && !name && !uid) if (!*argv && !pidfile && !name && !uid)
eerrorx("%s: --stop needs --exec, --pidfile," eerrorx("%s: --stop needs --exec, --pidfile,"
" --name or --user", applet); " --name or --user", applet);
@ -876,6 +879,7 @@ int start_stop_daemon(int argc, char **argv)
eerrorx("%s: --stdout and --stderr are only relevant" eerrorx("%s: --stdout and --stderr are only relevant"
" with --background", applet); " with --background", applet);
} }
/* Expand ~ */ /* Expand ~ */
if (ch_dir && *ch_dir == '~') if (ch_dir && *ch_dir == '~')
ch_dir = expand_home(home, ch_dir); ch_dir = expand_home(home, ch_dir);
@ -955,16 +959,16 @@ int start_stop_daemon(int argc, char **argv)
margv = nav ? nav : argv; margv = nav ? nav : argv;
if (stop || sig) { if (stop || sig) {
if (!sig) if (sig == 0)
sig = SIGTERM; sig = SIGTERM;
if (!stop) if (!stop)
oknodo = true; oknodo = true;
if (!TAILQ_FIRST(&schedule)) { if (retry)
if (test || oknodo) parse_schedule(retry, sig);
else if (test || oknodo)
parse_schedule("0", sig); parse_schedule("0", sig);
else else
parse_schedule(NULL, sig); parse_schedule(NULL, sig);
}
i = run_stop_schedule(exec, (const char *const *)margv, i = run_stop_schedule(exec, (const char *const *)margv,
pidfile, uid, quiet, verbose, test); pidfile, uid, quiet, verbose, test);