summaryrefslogtreecommitdiffstats
path: root/init/builtins.cpp
diff options
context:
space:
mode:
authorTom Cherry <tomcherry@google.com>2017-09-18 21:33:26 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-09-18 21:33:26 +0000
commit424ed42fb4382c7edbfe7239c9fde56ee87449c5 (patch)
treec5d38ffb6e3ceb56ba81a5bcb3ae6fe8b562f3f7 /init/builtins.cpp
parent2fb5fa336bc93ba555642998a9d5becd333f1429 (diff)
parent3631c545b8e3256c5aba2269491912e3f568cd99 (diff)
downloadsystem_core-424ed42fb4382c7edbfe7239c9fde56ee87449c5.tar.gz
system_core-424ed42fb4382c7edbfe7239c9fde56ee87449c5.tar.bz2
system_core-424ed42fb4382c7edbfe7239c9fde56ee87449c5.zip
Merge "init: add exec_background command"
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 5f359cfad..be245732b 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) {
@@ -959,6 +972,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}},