aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2017-05-22 11:29:14 -0500
committerWilliam Hubbs <w.d.hubbs@gmail.com>2017-05-22 11:29:23 -0500
commita77ee2e94191ba1a286b8a6835f76556481566ba (patch)
tree46dee3e9e22614ec1aec1ca24deb0016e10f8bb9 /src
parent49b8a573a195f4b2cee992cd10678694da0a6f4f (diff)
init: add ability to switch to single user mode
Diffstat (limited to 'src')
-rw-r--r--src/rc/openrc-init.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/rc/openrc-init.c b/src/rc/openrc-init.c
index 8abe0dd6..398259cc 100644
--- a/src/rc/openrc-init.c
+++ b/src/rc/openrc-init.c
@@ -105,6 +105,14 @@ static void handle_shutdown(const char *runlevel, int cmd)
reboot(cmd);
}
+static void handle_single(void)
+{
+ pid_t pid;
+
+ pid = do_openrc("single");
+ while (waitpid(pid, NULL, 0) != pid);
+}
+
static void reap_zombies(void)
{
pid_t pid;
@@ -201,6 +209,8 @@ int main(int argc, char **argv)
handle_shutdown("reboot", RB_AUTOBOOT);
else if (strcmp(buf, "reexec") == 0)
handle_reexec(argv[0]);
+ else if (strcmp(buf, "single") == 0)
+ handle_single();
}
return 0;
}