1 |
commit: b18be3f970eba04589977438faaa726b5c3a6cd2 |
2 |
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com> |
3 |
AuthorDate: Sat Oct 28 00:22:09 2017 +0000 |
4 |
Commit: William Hubbs <williamh <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Oct 28 00:25:40 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=b18be3f9 |
7 |
|
8 |
supervise-daemon: use RC_SVCNAME as the first argument to the daemon |
9 |
|
10 |
This makes ps show which service the supervisor is monitoring. |
11 |
|
12 |
sh/supervise-daemon.sh | 4 ++-- |
13 |
src/rc/supervise-daemon.c | 24 ++++++++++++++++-------- |
14 |
2 files changed, 18 insertions(+), 10 deletions(-) |
15 |
|
16 |
diff --git a/sh/supervise-daemon.sh b/sh/supervise-daemon.sh |
17 |
index e5d8d461..f6e599d5 100644 |
18 |
--- a/sh/supervise-daemon.sh |
19 |
+++ b/sh/supervise-daemon.sh |
20 |
@@ -22,7 +22,7 @@ supervise_start() |
21 |
# The eval call is necessary for cases like: |
22 |
# command_args="this \"is a\" test" |
23 |
# to work properly. |
24 |
- eval supervise-daemon --start \ |
25 |
+ eval supervise-daemon "${RC_SVCNAME}" --start \ |
26 |
${retry:+--retry} $retry \ |
27 |
${chroot:+--chroot} $chroot \ |
28 |
${pidfile:+--pidfile} $pidfile \ |
29 |
@@ -49,7 +49,7 @@ supervise_stop() |
30 |
pidfile="${startpidfile:-$pidfile}" |
31 |
[ -n "$pidfile" ] || return 0 |
32 |
ebegin "Stopping ${name:-$RC_SVCNAME}" |
33 |
- supervise-daemon --stop \ |
34 |
+ supervise-daemon "${RC_SVCNAME}" --stop \ |
35 |
${pidfile:+--pidfile} $chroot$pidfile \ |
36 |
${stopsig:+--signal} $stopsig |
37 |
|
38 |
|
39 |
diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c |
40 |
index 1d0c3407..3989cbc7 100644 |
41 |
--- a/src/rc/supervise-daemon.c |
42 |
+++ b/src/rc/supervise-daemon.c |
43 |
@@ -561,8 +561,13 @@ int main(int argc, char **argv) |
44 |
applet = basename_c(argv[0]); |
45 |
atexit(cleanup); |
46 |
svcname = getenv("RC_SVCNAME"); |
47 |
+ if (!svcname) |
48 |
+ eerrorx("%s: The RC_SVCNAME environment variable is not set", applet); |
49 |
openlog(applet, LOG_PID, LOG_DAEMON); |
50 |
|
51 |
+ if (argc >= 1 && svcname && strcmp(argv[1], svcname)) |
52 |
+ eerrorx("%s: the first argument must be %s", applet, svcname); |
53 |
+ |
54 |
if ((tmp = getenv("SSD_NICELEVEL"))) |
55 |
if (sscanf(tmp, "%d", &nicelevel) != 1) |
56 |
eerror("%s: invalid nice level `%s' (SSD_NICELEVEL)", |
57 |
@@ -583,6 +588,17 @@ int main(int argc, char **argv) |
58 |
} |
59 |
} |
60 |
|
61 |
+ *cmdline = '\0'; |
62 |
+ c = argv; |
63 |
+ while (c && *c) { |
64 |
+ strcat(cmdline, *c); |
65 |
+ strcat(cmdline, " "); |
66 |
+ c++; |
67 |
+ } |
68 |
+ if (svcname) { |
69 |
+ argc--; |
70 |
+ argv++; |
71 |
+ } |
72 |
while ((opt = getopt_long(argc, argv, getoptstring, longopts, |
73 |
(int *) 0)) != -1) |
74 |
switch (opt) { |
75 |
@@ -721,14 +737,6 @@ int main(int argc, char **argv) |
76 |
|
77 |
if (!pidfile && !reexec) |
78 |
eerrorx("%s: --pidfile must be specified", applet); |
79 |
- |
80 |
- *cmdline = '\0'; |
81 |
- c = argv; |
82 |
- while (c && *c) { |
83 |
- strcat(cmdline, *c); |
84 |
- strcat(cmdline, " "); |
85 |
- c++; |
86 |
- } |
87 |
endpwent(); |
88 |
argc -= optind; |
89 |
argv += optind; |