summaryrefslogtreecommitdiff
path: root/init/builtins.cpp
diff options
context:
space:
mode:
authorTom Cherry <tomcherry@google.com>2017-09-18 21:37:38 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-09-18 21:37:38 +0000
commita6d75117e26337a22cf727fc66e0a189ff614d8d (patch)
tree0bb5b28faf9114b092820b5ead8689b2e27c3227 /init/builtins.cpp
parent52fe6feeb4da1b0ff3ca62e55f9eb2bca38f6544 (diff)
parent424ed42fb4382c7edbfe7239c9fde56ee87449c5 (diff)
Merge "init: add exec_background command"
am: 424ed42fb4 Change-Id: I9529146ea9b29b2fb2e2c92f3533efc4e3106943
Diffstat (limited to 'init/builtins.cpp')
-rw-r--r--init/builtins.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 96e78cbd4..0fef8838d 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -148,6 +148,19 @@ static Result<Success> do_exec(const std::vector<std::string>& args) {
return Success();
}
+static Result<Success> do_exec_background(const std::vector<std::string>& args) {
+ auto service = Service::MakeTemporaryOneshotService(args);
+ if (!service) {
+ return Error() << "Could not create exec background service";
+ }
+ if (auto result = service->Start(); !result) {
+ return Error() << "Could not start exec background service: " << result.error();
+ }
+
+ ServiceList::GetInstance().AddService(std::move(service));
+ return Success();
+}
+
static Result<Success> do_exec_start(const std::vector<std::string>& args) {
Service* service = ServiceList::GetInstance().FindService(args[1]);
if (!service) {
@@ -978,6 +991,7 @@ const BuiltinFunctionMap::Map& BuiltinFunctionMap::map() const {
{"domainname", {1, 1, do_domainname}},
{"enable", {1, 1, do_enable}},
{"exec", {1, kMax, do_exec}},
+ {"exec_background", {1, kMax, do_exec_background}},
{"exec_start", {1, 1, do_exec_start}},
{"export", {2, 2, do_export}},
{"hostname", {1, 1, do_hostname}},