summaryrefslogtreecommitdiff
path: root/init/builtins.cpp
diff options
context:
space:
mode:
authorTom Cherry <tomcherry@google.com>2017-03-27 16:27:30 -0700
committerTom Cherry <tomcherry@google.com>2017-03-27 17:41:27 -0700
commitb27004aa05039b5196f1e878169dca41b68aadd6 (patch)
treea859e2269ff0b19e4ff92634507be14eab7de084 /init/builtins.cpp
parentb15429c0eade8a5f9b456c5f0aa57eec697e9ff2 (diff)
init: add exec_start command
Exec services may also want to set other service flags such as priority. Instead of expanding the exec syntax to handle this, create a new command, exec_start, that will treat an existing service definition as an exec service. The new exec_start command will start the service then halt init from executing further commands until the service has exited. This change additionally encapsulates the waiting_for_exec logic into ServiceManager and removes the ambiguous 'bool' return value from Reap() which previously indicated if a Reaped service was an exec service or not. Bug: 36511808 Bug: 36102163 Test: Bullhead boots, services run with exec_start as they do exec. Change-Id: I44f775cf1c1dd81d5c715f44fdc150c651a2c80a
Diffstat (limited to 'init/builtins.cpp')
-rw-r--r--init/builtins.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 32e9ef642..c860e4001 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -161,19 +161,11 @@ static int do_enable(const std::vector<std::string>& args) {
}
static int do_exec(const std::vector<std::string>& args) {
- Service* svc = ServiceManager::GetInstance().MakeExecOneshotService(args);
- if (!svc) {
- return -1;
- }
- if (!start_waiting_for_exec()) {
- return -1;
- }
- if (!svc->Start()) {
- stop_waiting_for_exec();
- ServiceManager::GetInstance().RemoveService(*svc);
- return -1;
- }
- return 0;
+ return ServiceManager::GetInstance().Exec(args) ? 0 : -1;
+}
+
+static int do_exec_start(const std::vector<std::string>& args) {
+ return ServiceManager::GetInstance().ExecStart(args[1]) ? 0 : -1;
}
static int do_export(const std::vector<std::string>& args) {
@@ -892,6 +884,7 @@ static int do_init_user0(const std::vector<std::string>& args) {
BuiltinFunctionMap::Map& BuiltinFunctionMap::map() const {
constexpr std::size_t kMax = std::numeric_limits<std::size_t>::max();
+ // clang-format off
static const Map builtin_functions = {
{"bootchart", {1, 1, do_bootchart}},
{"chmod", {2, 2, do_chmod}},
@@ -903,6 +896,7 @@ BuiltinFunctionMap::Map& BuiltinFunctionMap::map() const {
{"domainname", {1, 1, do_domainname}},
{"enable", {1, 1, do_enable}},
{"exec", {1, kMax, do_exec}},
+ {"exec_start", {1, 1, do_exec_start}},
{"export", {2, 2, do_export}},
{"hostname", {1, 1, do_hostname}},
{"ifup", {1, 1, do_ifup}},
@@ -936,5 +930,6 @@ BuiltinFunctionMap::Map& BuiltinFunctionMap::map() const {
{"wait_for_prop", {2, 2, do_wait_for_prop}},
{"write", {2, 2, do_write}},
};
+ // clang-format on
return builtin_functions;
}