summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-11-03 21:06:45 +0000
committerRoy Marples <roy@marples.name>2008-11-03 21:06:45 +0000
commit8a76c273253180a5872ce909ae63d79fafc1d8ca (patch)
tree265ff4f5a6568ac3847056e8bf8840f16d6b8933
parent7467440a294077af40b40dff49144ffc66cd614a (diff)
downloadopenrc-8a76c273253180a5872ce909ae63d79fafc1d8ca.tar.gz
openrc-8a76c273253180a5872ce909ae63d79fafc1d8ca.tar.bz2
openrc-8a76c273253180a5872ce909ae63d79fafc1d8ca.tar.xz
Fix sending signals, #121.
-rw-r--r--src/rc/start-stop-daemon.c52
1 files changed, 32 insertions, 20 deletions
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index b85a5f3..a4750e0 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -608,7 +608,8 @@ int start_stop_daemon(int argc, char **argv)
#endif
int opt;
- bool start = true;
+ bool start = false;
+ bool stop = false;
bool oknodo = false;
bool test = false;
bool quiet;
@@ -617,7 +618,7 @@ int start_stop_daemon(int argc, char **argv)
char *startas = NULL;
char *name = NULL;
char *pidfile = NULL;
- int sig = SIGTERM;
+ int sig = 0;
int nicelevel = 0;
bool background = false;
bool makepidfile = false;
@@ -676,9 +677,8 @@ int start_stop_daemon(int argc, char **argv)
(int *) 0)) != -1)
switch (opt) {
case 'K': /* --stop */
- start = false;
+ stop = true;
break;
-
case 'N': /* --nice */
if (sscanf(optarg, "%d", &nicelevel) != 1)
eerrorx("%s: invalid nice level `%s'",
@@ -844,23 +844,35 @@ int start_stop_daemon(int argc, char **argv)
else
*--argv = exec;
- if (start && !exec)
- eerrorx("%s: nothing to start", applet);
-
- if (!start && !*argv && !pidfile && !name && !uid)
- eerrorx("%s: --stop needs --exec, --pidfile, --name or --user", applet);
-
- if (makepidfile && !pidfile)
- eerrorx("%s: --make-pidfile is only relevant with --pidfile", applet);
-
- 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 (stop || sig) {
+ 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) {
+ if (stop || sig) {
+ if (!sig)
+ sig = SIGTERM;
+ if (!stop)
+ oknodo = true;
if (!TAILQ_FIRST(&schedule)) {
if (test || oknodo)
parse_schedule("0", sig);