summaryrefslogtreecommitdiff
path: root/src/initctl.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2011-07-30 18:23:10 +0200
committerLennart Poettering <lennart@poettering.net>2011-08-01 23:22:24 +0200
commit46e964c5ce20ce4b46b9187376057081eb71bc55 (patch)
tree1ff87020d889ce0fb24eb2c5ae927edd402b095f /src/initctl.c
parentcc9784c6d12b1ee73dae22b86c3aac1d08346623 (diff)
initctl: support 'telinit u/q'
We send SIGTERM (resp., SIGHUP) when we receive request for changing to runlevel 'u' (resp., 'q'). As initctl is already async, we just send the signals rather than first attempting to connect to sytemd over dbus and then falling back to kill.
Diffstat (limited to 'src/initctl.c')
-rw-r--r--src/initctl.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/initctl.c b/src/initctl.c
index 7096a824b0..f36f1cc704 100644
--- a/src/initctl.c
+++ b/src/initctl.c
@@ -165,7 +165,24 @@ static void request_process(Server *s, const struct init_request *req) {
if (!isprint(req->runlevel))
log_error("Got invalid runlevel. Ignoring.");
else
- change_runlevel(s, req->runlevel);
+ switch (req->runlevel) {
+
+ /* we are async anyway, so just use kill for reexec/reload */
+ case 'u':
+ case 'U':
+ if (kill(1, SIGTERM) < 0)
+ log_error("kill() failed: %m");
+ break;
+
+ case 'q':
+ case 'Q':
+ if (kill(1, SIGHUP) < 0)
+ log_error("kill() failed: %m");
+ break;
+
+ default:
+ change_runlevel(s, req->runlevel);
+ }
return;
case INIT_CMD_POWERFAIL: