Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 13c65741 authored by Suren Baghdasaryan's avatar Suren Baghdasaryan Committed by Gerrit Code Review
Browse files

Merge "init: Add task_profiles init command"

parents c9412363 c9c0bbac
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -322,6 +322,10 @@ runs the service.
  This is mutually exclusive with the console option, which additionally connects stdin to the
  given console.

`task_profiles <profile> [ <profile>\* ]`
> Set task profiles for the process when it forks. This is designed to replace the use of
  writepid option for moving a process into a cgroup.

`timeout_period <seconds>`
> Provide a timeout after which point the service will be killed. The oneshot keyword is respected
  here, so oneshot services do not automatically restart, however all other services will.
@@ -356,6 +360,8 @@ runs the service.
  cgroup/cpuset usage. If no files under /dev/cpuset/ are specified, but the
  system property 'ro.cpuset.default' is set to a non-empty cpuset name (e.g.
  '/foreground'), then the pid is written to file /dev/cpuset/_cpuset\_name_/tasks.
  The use of this option for moving a process into a cgroup is obsolete. Please
  use task_profiles option instead.


Triggers
+4 −0
Original line number Diff line number Diff line
@@ -513,6 +513,10 @@ Result<void> Service::Start() {
            LOG(ERROR) << "failed to write pid to files: " << result.error();
        }

        if (task_profiles_.size() > 0 && !SetTaskProfiles(getpid(), task_profiles_)) {
            LOG(ERROR) << "failed to set task profiles";
        }

        // As requested, set our gid, supplemental gids, uid, context, and
        // priority. Aborts on failure.
        SetProcessAttributesAndCaps();
+2 −0
Original line number Diff line number Diff line
@@ -170,6 +170,8 @@ class Service {

    std::vector<std::string> writepid_files_;

    std::vector<std::string> task_profiles_;

    std::set<std::string> interfaces_;  // e.g. some.package.foo@1.0::IBaz/instance-name

    // keycodes for triggering this service via /dev/input/input*
+7 −0
Original line number Diff line number Diff line
@@ -360,6 +360,12 @@ Result<void> ServiceParser::ParseShutdown(std::vector<std::string>&& args) {
    return Error() << "Invalid shutdown option";
}

Result<void> ServiceParser::ParseTaskProfiles(std::vector<std::string>&& args) {
    args.erase(args.begin());
    service_->task_profiles_ = std::move(args);
    return {};
}

Result<void> ServiceParser::ParseTimeoutPeriod(std::vector<std::string>&& args) {
    int period;
    if (!ParseInt(args[1], &period, 1)) {
@@ -529,6 +535,7 @@ const KeywordMap<ServiceParser::OptionParser>& ServiceParser::GetParserMap() con
        {"sigstop",                 {0,     0,    &ServiceParser::ParseSigstop}},
        {"socket",                  {3,     6,    &ServiceParser::ParseSocket}},
        {"stdio_to_kmsg",           {0,     0,    &ServiceParser::ParseStdioToKmsg}},
        {"task_profiles",           {1,     kMax, &ServiceParser::ParseTaskProfiles}},
        {"timeout_period",          {1,     1,    &ServiceParser::ParseTimeoutPeriod}},
        {"updatable",               {0,     0,    &ServiceParser::ParseUpdatable}},
        {"user",                    {1,     1,    &ServiceParser::ParseUser}},
+1 −0
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ class ServiceParser : public SectionParser {
    Result<void> ParseSigstop(std::vector<std::string>&& args);
    Result<void> ParseSocket(std::vector<std::string>&& args);
    Result<void> ParseStdioToKmsg(std::vector<std::string>&& args);
    Result<void> ParseTaskProfiles(std::vector<std::string>&& args);
    Result<void> ParseTimeoutPeriod(std::vector<std::string>&& args);
    Result<void> ParseFile(std::vector<std::string>&& args);
    Result<void> ParseUser(std::vector<std::string>&& args);