aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2009-04-22 10:45:01 +0000
committerRoy Marples <roy@marples.name>2009-04-22 10:45:01 +0000
commitf326f688f6a9d49936f4e5e6e6b9db67957c6797 (patch)
treea6c9d4e84a41fadf60239b0d19ea69342396456a
parent588c9da0abd52b88e95898e6801799c980d14494 (diff)
Add the -i, --interpreted option.
This enables the code to include the daemons interpreter when matching process name which fixes bug #164. Existing init scripts that rely on the old behaviour will need to be fixed.
-rw-r--r--src/rc/start-stop-daemon.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index 90e25747..0d612c48 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -549,7 +549,7 @@ expand_home(const char *home, const char *path)
}
#include "_usage.h"
-#define getoptstring "KN:R:Sbc:d:e:g:k:mn:op:s:tu:r:w:x:1:2:" getoptstring_COMMON
+#define getoptstring "KN:R:Sbc:d:e:g:ik:mn:op:s:tu:r:w:x:1:2:" getoptstring_COMMON
static const struct option longopts[] = {
{ "stop", 0, NULL, 'K'},
{ "nicelevel", 1, NULL, 'N'},
@@ -562,6 +562,7 @@ static const struct option longopts[] = {
{ "env", 1, NULL, 'e'},
{ "umask", 1, NULL, 'k'},
{ "group", 1, NULL, 'g'},
+ { "interpreted", 0, NULL, 'i'},
{ "make-pidfile", 0, NULL, 'm'},
{ "name", 1, NULL, 'n'},
{ "oknodo", 0, NULL, 'o'},
@@ -588,6 +589,7 @@ static const char * const longopts_help[] = {
"Set an environment string",
"Set the umask for the daemon",
"Change the process group",
+ "Match process name by interpreter",
"Create a pidfile",
"Match process name",
"deprecated",
@@ -633,6 +635,7 @@ int start_stop_daemon(int argc, char **argv)
int nicelevel = 0;
bool background = false;
bool makepidfile = false;
+ bool interpreted = false;
uid_t uid = 0;
gid_t gid = 0;
char *home = NULL;
@@ -772,6 +775,10 @@ int start_stop_daemon(int argc, char **argv)
gid = gr->gr_gid;
break;
+ case 'i': /* --interpreted */
+ interpreted = true;
+ break;
+
case 'k':
if (parse_mode(&numask, optarg))
eerrorx("%s: invalid mode `%s'",
@@ -933,7 +940,7 @@ int start_stop_daemon(int argc, char **argv)
/* If we don't have a pidfile we should check if it's interpreted
* or not. If it we, we need to pass the interpreter through
* to our daemon calls to find it correctly. */
- if (!pidfile) {
+ if (interpreted && !pidfile) {
fp = fopen(exec_file, "r");
if (fp) {
fgets(line, sizeof(line), fp);