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.
This commit is contained in:
parent
588c9da0ab
commit
f326f688f6
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user