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"
|
#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[] = {
|
static const struct option longopts[] = {
|
||||||
{ "stop", 0, NULL, 'K'},
|
{ "stop", 0, NULL, 'K'},
|
||||||
{ "nicelevel", 1, NULL, 'N'},
|
{ "nicelevel", 1, NULL, 'N'},
|
||||||
@ -562,6 +562,7 @@ static const struct option longopts[] = {
|
|||||||
{ "env", 1, NULL, 'e'},
|
{ "env", 1, NULL, 'e'},
|
||||||
{ "umask", 1, NULL, 'k'},
|
{ "umask", 1, NULL, 'k'},
|
||||||
{ "group", 1, NULL, 'g'},
|
{ "group", 1, NULL, 'g'},
|
||||||
|
{ "interpreted", 0, NULL, 'i'},
|
||||||
{ "make-pidfile", 0, NULL, 'm'},
|
{ "make-pidfile", 0, NULL, 'm'},
|
||||||
{ "name", 1, NULL, 'n'},
|
{ "name", 1, NULL, 'n'},
|
||||||
{ "oknodo", 0, NULL, 'o'},
|
{ "oknodo", 0, NULL, 'o'},
|
||||||
@ -588,6 +589,7 @@ static const char * const longopts_help[] = {
|
|||||||
"Set an environment string",
|
"Set an environment string",
|
||||||
"Set the umask for the daemon",
|
"Set the umask for the daemon",
|
||||||
"Change the process group",
|
"Change the process group",
|
||||||
|
"Match process name by interpreter",
|
||||||
"Create a pidfile",
|
"Create a pidfile",
|
||||||
"Match process name",
|
"Match process name",
|
||||||
"deprecated",
|
"deprecated",
|
||||||
@ -633,6 +635,7 @@ int start_stop_daemon(int argc, char **argv)
|
|||||||
int nicelevel = 0;
|
int nicelevel = 0;
|
||||||
bool background = false;
|
bool background = false;
|
||||||
bool makepidfile = false;
|
bool makepidfile = false;
|
||||||
|
bool interpreted = false;
|
||||||
uid_t uid = 0;
|
uid_t uid = 0;
|
||||||
gid_t gid = 0;
|
gid_t gid = 0;
|
||||||
char *home = NULL;
|
char *home = NULL;
|
||||||
@ -772,6 +775,10 @@ int start_stop_daemon(int argc, char **argv)
|
|||||||
gid = gr->gr_gid;
|
gid = gr->gr_gid;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'i': /* --interpreted */
|
||||||
|
interpreted = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'k':
|
case 'k':
|
||||||
if (parse_mode(&numask, optarg))
|
if (parse_mode(&numask, optarg))
|
||||||
eerrorx("%s: invalid mode `%s'",
|
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
|
/* 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
|
* or not. If it we, we need to pass the interpreter through
|
||||||
* to our daemon calls to find it correctly. */
|
* to our daemon calls to find it correctly. */
|
||||||
if (!pidfile) {
|
if (interpreted && !pidfile) {
|
||||||
fp = fopen(exec_file, "r");
|
fp = fopen(exec_file, "r");
|
||||||
if (fp) {
|
if (fp) {
|
||||||
fgets(line, sizeof(line), fp);
|
fgets(line, sizeof(line), fp);
|
||||||
|
Loading…
Reference in New Issue
Block a user