Fix sending signals, #121.
This commit is contained in:
parent
7467440a29
commit
8a76c27325
@ -608,7 +608,8 @@ int start_stop_daemon(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int opt;
|
int opt;
|
||||||
bool start = true;
|
bool start = false;
|
||||||
|
bool stop = false;
|
||||||
bool oknodo = false;
|
bool oknodo = false;
|
||||||
bool test = false;
|
bool test = false;
|
||||||
bool quiet;
|
bool quiet;
|
||||||
@ -617,7 +618,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;
|
||||||
int sig = SIGTERM;
|
int sig = 0;
|
||||||
int nicelevel = 0;
|
int nicelevel = 0;
|
||||||
bool background = false;
|
bool background = false;
|
||||||
bool makepidfile = false;
|
bool makepidfile = false;
|
||||||
@ -676,9 +677,8 @@ int start_stop_daemon(int argc, char **argv)
|
|||||||
(int *) 0)) != -1)
|
(int *) 0)) != -1)
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'K': /* --stop */
|
case 'K': /* --stop */
|
||||||
start = false;
|
stop = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'N': /* --nice */
|
case 'N': /* --nice */
|
||||||
if (sscanf(optarg, "%d", &nicelevel) != 1)
|
if (sscanf(optarg, "%d", &nicelevel) != 1)
|
||||||
eerrorx("%s: invalid nice level `%s'",
|
eerrorx("%s: invalid nice level `%s'",
|
||||||
@ -844,23 +844,35 @@ int start_stop_daemon(int argc, char **argv)
|
|||||||
else
|
else
|
||||||
*--argv = exec;
|
*--argv = exec;
|
||||||
|
|
||||||
if (start && !exec)
|
if (stop || sig) {
|
||||||
eerrorx("%s: nothing to start", applet);
|
if ( !*argv && !pidfile && !name && !uid)
|
||||||
|
eerrorx("%s: --stop needs --exec, --pidfile,"
|
||||||
|
" --name or --user", applet);
|
||||||
|
if (background)
|
||||||
|
eerrorx("%s: --background is only relevant with"
|
||||||
|
" --start", applet);
|
||||||
|
if (makepidfile)
|
||||||
|
eerrorx("%s: --make-pidfile is only relevant with"
|
||||||
|
" --start", applet);
|
||||||
|
if (redirect_stdout || redirect_stderr)
|
||||||
|
eerrorx("%s: --stdout and --stderr are only relevant"
|
||||||
|
" with --start", applet);
|
||||||
|
} else {
|
||||||
|
if (!exec)
|
||||||
|
eerrorx("%s: nothing to start", applet);
|
||||||
|
if (makepidfile && !pidfile)
|
||||||
|
eerrorx("%s: --make-pidfile is only relevant with"
|
||||||
|
" --pidfile", applet);
|
||||||
|
if ((redirect_stdout || redirect_stderr) && !background)
|
||||||
|
eerrorx("%s: --stdout and --stderr are only relevant"
|
||||||
|
" with --background", applet);
|
||||||
|
}
|
||||||
|
|
||||||
if (!start && !*argv && !pidfile && !name && !uid)
|
if (stop || sig) {
|
||||||
eerrorx("%s: --stop needs --exec, --pidfile, --name or --user", applet);
|
if (!sig)
|
||||||
|
sig = SIGTERM;
|
||||||
if (makepidfile && !pidfile)
|
if (!stop)
|
||||||
eerrorx("%s: --make-pidfile is only relevant with --pidfile", applet);
|
oknodo = true;
|
||||||
|
|
||||||
if (background && !start)
|
|
||||||
eerrorx("%s: --background is only relevant with --start", applet);
|
|
||||||
|
|
||||||
if ((redirect_stdout || redirect_stderr) && !background)
|
|
||||||
eerrorx("%s: --stdout and --stderr are only relevant with --background",
|
|
||||||
applet);
|
|
||||||
|
|
||||||
if (!start) {
|
|
||||||
if (!TAILQ_FIRST(&schedule)) {
|
if (!TAILQ_FIRST(&schedule)) {
|
||||||
if (test || oknodo)
|
if (test || oknodo)
|
||||||
parse_schedule("0", sig);
|
parse_schedule("0", sig);
|
||||||
|
Loading…
Reference in New Issue
Block a user