summaryrefslogtreecommitdiffstats
path: root/init/init.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-06-12 18:02:20 -0700
committerElliott Hughes <enh@google.com>2015-06-17 15:21:52 -0700
commite79d0d556f894696291cef89ccaf64efe45d11ad (patch)
tree514b5edeefddc7fb615f0304a445b39598b5e62a /init/init.cpp
parentd50393057a6551c3bb498ed3a3bb7bd9eeb48225 (diff)
downloadsystem_core-e79d0d556f894696291cef89ccaf64efe45d11ad.zip
system_core-e79d0d556f894696291cef89ccaf64efe45d11ad.tar.gz
system_core-e79d0d556f894696291cef89ccaf64efe45d11ad.tar.bz2
init support for cgroups.
This adds the "writepid" option that instructs init to write the child's pid to the given filenames (such as /dev/cpuctl/bg_non_interactive/cgroup.procs and/or /dev/cpuset/foreground/cgroup.procs). Bug: http://b/21163745 Change-Id: I121bb22aa208bc99c4fb334eb552fdd5bcc47c1a (cherry picked from commit d62f0608d9d67bf647cf15debbd163e84584fe44)
Diffstat (limited to 'init/init.cpp')
-rw-r--r--init/init.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/init/init.cpp b/init/init.cpp
index 85d7909..93fe944 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -290,6 +290,16 @@ void service_start(struct service *svc, const char *dynamic_args)
freecon(scon);
scon = NULL;
+ if (svc->writepid_files_) {
+ std::string pid_str = android::base::StringPrintf("%d", pid);
+ for (auto& file : *svc->writepid_files_) {
+ if (!android::base::WriteStringToFile(pid_str, file)) {
+ ERROR("couldn't write %s to %s: %s\n",
+ pid_str.c_str(), file.c_str(), strerror(errno));
+ }
+ }
+ }
+
if (svc->ioprio_class != IoSchedClass_NONE) {
if (android_set_ioprio(getpid(), svc->ioprio_class, svc->ioprio_pri)) {
ERROR("Failed to set pid %d ioprio = %d,%d: %s\n",