-rw-r--r-- | NEWS.xml | 2 | ||||
-rw-r--r-- | man/dudki.8.in | 11 | ||||
-rw-r--r-- | src/dudki.cc | 20 |
3 files changed, 29 insertions, 4 deletions
@@ -1,8 +1,8 @@ | |||
1 | <?xml version="1.0" encoding="us-ascii"?> | 1 | <?xml version="1.0" encoding="us-ascii"?> |
2 | <news> | 2 | <news> |
3 | <version version="0.2" date="July 23rd, 2004"> | 3 | <version version="0.2" date="July 23rd, 2004"> |
4 | <ni>now dudki sends signals to the processes being monitored from the command line</ni> | 4 | <ni>now dudki sends arbitrary signals to the processes being monitored from the command line</ni> |
5 | </version> | 5 | </version> |
6 | <version version="0.1" date="July 21st, 2004"> | 6 | <version version="0.1" date="July 21st, 2004"> |
7 | <ni><kbd>initgroups()</kbd> called before executing <kbd>RestartCommand</kbd></ni> | 7 | <ni><kbd>initgroups()</kbd> called before executing <kbd>RestartCommand</kbd></ni> |
8 | <ni>more civilized way of restarting on <kbd>SIGHUP</kbd></ni> | 8 | <ni>more civilized way of restarting on <kbd>SIGHUP</kbd></ni> |
diff --git a/man/dudki.8.in b/man/dudki.8.in index 05db733..be60f53 100644 --- a/man/dudki.8.in +++ b/man/dudki.8.in | |||
@@ -1,11 +1,11 @@ | |||
1 | .TH dudki 8 "June 9th, 2004" "dudki(8)" "Klever Group (http://www.klever.net/)" | 1 | .TH dudki 8 "July 23rd, 2004" "dudki(8)" "Klever Group (http://www.klever.net/)" |
2 | .hla en | 2 | .hla en |
3 | .ds longopt @HAVE_GETOPT_LONG@ | 3 | .ds longopt @HAVE_GETOPT_LONG@ |
4 | 4 | ||
5 | .SH NAME | 5 | .SH NAME |
6 | 6 | ||
7 | dudki \- a process monitoring daemon | 7 | dudki \- a process maintenance daemon |
8 | 8 | ||
9 | .SH SYNOPSYS | 9 | .SH SYNOPSYS |
10 | 10 | ||
11 | \fBdudki\fR [\fB-h\fR] | 11 | \fBdudki\fR [\fB-h\fR] |
@@ -21,8 +21,10 @@ dudki \- a process monitoring daemon | |||
21 | [\fB-r\fR] | 21 | [\fB-r\fR] |
22 | .if \*[longopt] [\fB--reload\fR] | 22 | .if \*[longopt] [\fB--reload\fR] |
23 | [\fB-c\fR] | 23 | [\fB-c\fR] |
24 | .if \*[longopt] [\fB--check\fR] | 24 | .if \*[longopt] [\fB--check\fR] |
25 | [\fB-s\fR \fIsignum\fR] | ||
26 | .if \*[longopt] [\fB--signal=\fR\fIsignum\fR] | ||
25 | [\fB-e\fR] | 27 | [\fB-e\fR] |
26 | .if \*[longopt] [\fB--ensure\fR] | 28 | .if \*[longopt] [\fB--ensure\fR] |
27 | [\fB-t\fR] | 29 | [\fB-t\fR] |
28 | .if \*[longopt] [\fB--test\fR] | 30 | .if \*[longopt] [\fB--test\fR] |
@@ -54,8 +56,13 @@ name specified on the command line, dudki kills his own running instance. | |||
54 | Reload the running instance by sending the \fBSIGHUP\fR signal. Like with | 56 | Reload the running instance by sending the \fBSIGHUP\fR signal. Like with |
55 | \fB-k\fR, if no process name specified on the command line, dudki sends | 57 | \fB-k\fR, if no process name specified on the command line, dudki sends |
56 | \fBSIGHUP\fR to his own running instance. | 58 | \fBSIGHUP\fR to his own running instance. |
57 | .TP | 59 | .TP |
60 | .ie \*[longopt] \fB-s\fR \fIsignum\fR, \fB--signal=\fR\fIsignum\fR | ||
61 | .el \fB-s\fR \fIsignum\fR | ||
62 | Send arbitrary signal to the names processes (or self, but it doesn't make much | ||
63 | sense). | ||
64 | .TP | ||
58 | .ie \*[longopt] \fB-c\fR, \fB--check\fR | 65 | .ie \*[longopt] \fB-c\fR, \fB--check\fR |
59 | .el \fB-c\fR | 66 | .el \fB-c\fR |
60 | Check if dudki is running. Exit with non-zero status if not. The same target | 67 | Check if dudki is running. Exit with non-zero status if not. The same target |
61 | rules as in \fB-k\fR and \fB-r\fR apply here. | 68 | rules as in \fB-k\fR and \fB-r\fR apply here. |
diff --git a/src/dudki.cc b/src/dudki.cc index e91ad5e..9562079 100644 --- a/src/dudki.cc +++ b/src/dudki.cc | |||
@@ -1,7 +1,8 @@ | |||
1 | #include <unistd.h> | 1 | #include <unistd.h> |
2 | #include <signal.h> | 2 | #include <signal.h> |
3 | #include <syslog.h> | 3 | #include <syslog.h> |
4 | #include <errno.h> | ||
4 | #include <iostream> | 5 | #include <iostream> |
5 | #include <fstream> | 6 | #include <fstream> |
6 | #include <stdexcept> | 7 | #include <stdexcept> |
7 | using namespace std; | 8 | using namespace std; |
@@ -67,9 +68,9 @@ int main(int argc,char **argv) { | |||
67 | op_test | 68 | op_test |
68 | } op = op_default; | 69 | } op = op_default; |
69 | int op_signum = 0; | 70 | int op_signum = 0; |
70 | while(true) { | 71 | while(true) { |
71 | #defineSHORTOPTSTRING "f:hVLrkcet" | 72 | #defineSHORTOPTSTRING "f:hVLrkcets:" |
72 | #ifdef HAVE_GETOPT_LONG | 73 | #ifdef HAVE_GETOPT_LONG |
73 | static struct option opts[] = { | 74 | static struct option opts[] = { |
74 | { "help", no_argument, 0, 'h' }, | 75 | { "help", no_argument, 0, 'h' }, |
75 | { "usage", no_argument, 0, 'h' }, | 76 | { "usage", no_argument, 0, 'h' }, |
@@ -77,8 +78,9 @@ int main(int argc,char **argv) { | |||
77 | { "license", no_argument, 0, 'L' }, | 78 | { "license", no_argument, 0, 'L' }, |
78 | { "config", required_argument, 0, 'f' }, | 79 | { "config", required_argument, 0, 'f' }, |
79 | { "kill", no_argument, 0, 'k' }, | 80 | { "kill", no_argument, 0, 'k' }, |
80 | { "reload", no_argument, 0, 'r' }, | 81 | { "reload", no_argument, 0, 'r' }, |
82 | { "signal", required_argument, 0, 's' }, | ||
81 | { "check", no_argument, 0, 'c' }, | 83 | { "check", no_argument, 0, 'c' }, |
82 | { "ensure", no_argument, 0, 'e' }, | 84 | { "ensure", no_argument, 0, 'e' }, |
83 | { "test", no_argument, 0, 't' }, | 85 | { "test", no_argument, 0, 't' }, |
84 | { NULL, 0, 0, 0 } | 86 | { NULL, 0, 0, 0 } |
@@ -103,8 +105,10 @@ int main(int argc,char **argv) { | |||
103 | " specify the configuration file to use\n" | 105 | " specify the configuration file to use\n" |
104 | "\n" | 106 | "\n" |
105 | " -k, --kill stop running instance (send SIGTERM)\n" | 107 | " -k, --kill stop running instance (send SIGTERM)\n" |
106 | " -r, --reload reload running instance (send SIGHUP)\n" | 108 | " -r, --reload reload running instance (send SIGHUP)\n" |
109 | " -s signum, --signal=signum\n" | ||
110 | " send the specified signal to the running process\n" | ||
107 | " -c, --check check if the process is running\n" | 111 | " -c, --check check if the process is running\n" |
108 | " (the above commands operate on dudki itself if no\n" | 112 | " (the above commands operate on dudki itself if no\n" |
109 | " process name has been specified)\n" | 113 | " process name has been specified)\n" |
110 | " -e, --ensure ensure that dudki is running\n" | 114 | " -e, --ensure ensure that dudki is running\n" |
@@ -116,8 +120,9 @@ int main(int argc,char **argv) { | |||
116 | " -f filename specify the configuration file to use\n" | 120 | " -f filename specify the configuration file to use\n" |
117 | "\n" | 121 | "\n" |
118 | " -k stop running instance (send SIGTERM)\n" | 122 | " -k stop running instance (send SIGTERM)\n" |
119 | " -r reload running instance (send SIGHUP)\n" | 123 | " -r reload running instance (send SIGHUP)\n" |
124 | " -s signum send the specified signal to the running process\n" | ||
120 | " -c check if the process is running\n" | 125 | " -c check if the process is running\n" |
121 | " (the above commands operate on dudki itself if no\n" | 126 | " (the above commands operate on dudki itself if no\n" |
122 | " process name has been specified)\n" | 127 | " process name has been specified)\n" |
123 | " -e ensure that dudki is running\n" | 128 | " -e ensure that dudki is running\n" |
@@ -172,8 +177,21 @@ int main(int argc,char **argv) { | |||
172 | exit(1); | 177 | exit(1); |
173 | } | 178 | } |
174 | op = op_test; | 179 | op = op_test; |
175 | break; | 180 | break; |
181 | case 's': | ||
182 | if(op!=op_default) { | ||
183 | cerr << "Can't obey two or more orders at once" << endl; | ||
184 | exit(1); | ||
185 | } | ||
186 | op = op_signal; | ||
187 | errno = 0; | ||
188 | op_signum = strtol(optarg,NULL,0); | ||
189 | if(errno) { | ||
190 | cerr << "Can't obtain the signal value" << endl; | ||
191 | exit(1); | ||
192 | } | ||
193 | break; | ||
176 | default: | 194 | default: |
177 | cerr << "Huh??" << endl; | 195 | cerr << "Huh??" << endl; |
178 | exit(1); | 196 | exit(1); |
179 | break; | 197 | break; |