summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Moreland <smoreland@google.com>2017-03-28 04:36:41 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-03-28 04:36:41 +0000
commit94f3ca87767fe84163012638053bf79ce01f693a (patch)
treedb968fddbd54746c3713306ed53ebe672ffcd5b8
parentb1bb1acd70c43667b3d36c2054253c88ca32e546 (diff)
parent0bd29405c079806bf063bc332f8d5c57f93c2c01 (diff)
downloadsystem_core-94f3ca87767fe84163012638053bf79ce01f693a.tar.gz
system_core-94f3ca87767fe84163012638053bf79ce01f693a.tar.bz2
system_core-94f3ca87767fe84163012638053bf79ce01f693a.zip
Merge "init: add class_restart" am: 8678872a00 am: ee7137208e
am: 0bd29405c0 Change-Id: I068cfa11752439d68b6f62a7cbc473250c7ab068
-rw-r--r--init/README.md6
-rw-r--r--init/builtins.cpp7
2 files changed, 12 insertions, 1 deletions
diff --git a/init/README.md b/init/README.md
index c77ea619e..024d5591b 100644
--- a/init/README.md
+++ b/init/README.md
@@ -280,6 +280,9 @@ Commands
currently running, without disabling them. They can be restarted
later using `class_start`.
+`class_restart <serviceclass>`
+> Restarts all services of the specified class.
+
`copy <src> <dst>`
> Copies a file. Similar to write, but useful for binary/large
amounts of data.
@@ -359,7 +362,8 @@ Commands
"sys.powerctl" system property, used to implement rebooting.
`restart <service>`
-> Like stop, but doesn't disable the service.
+> Stops and restarts a running service, does nothing if the service is currently
+ restarting, otherwise, it just starts the service.
`restorecon <path> [ <path>\* ]`
> Restore the file named by _path_ to the security context specified
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 32e9ef642..95f1aa0f8 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -148,6 +148,12 @@ static int do_class_reset(const std::vector<std::string>& args) {
return 0;
}
+static int do_class_restart(const std::vector<std::string>& args) {
+ ServiceManager::GetInstance().
+ ForEachServiceInClass(args[1], [] (Service* s) { s->Restart(); });
+ return 0;
+}
+
static int do_domainname(const std::vector<std::string>& args) {
return write_file("/proc/sys/kernel/domainname", args[1].c_str()) ? 0 : 1;
}
@@ -897,6 +903,7 @@ BuiltinFunctionMap::Map& BuiltinFunctionMap::map() const {
{"chmod", {2, 2, do_chmod}},
{"chown", {2, 3, do_chown}},
{"class_reset", {1, 1, do_class_reset}},
+ {"class_restart", {1, 1, do_class_restart}},
{"class_start", {1, 1, do_class_start}},
{"class_stop", {1, 1, do_class_stop}},
{"copy", {2, 2, do_copy}},