diff options
author | Anestis Bechtsoudis <anestis@census-labs.com> | 2016-02-05 16:38:48 +0200 |
---|---|---|
committer | Anestis Bechtsoudis <anestis@census-labs.com> | 2016-02-05 16:49:28 +0200 |
commit | b702b46f688bc3ba7f8dc2d35c6eb25482366c4c (patch) | |
tree | b9181e05f85e2d81b5dc18d06c4aec3fa7665ed1 | |
parent | 14c06e0769817d81f18fcdc41132747ffc158745 (diff) | |
download | core-b702b46f688bc3ba7f8dc2d35c6eb25482366c4c.tar.gz core-b702b46f688bc3ba7f8dc2d35c6eb25482366c4c.tar.bz2 core-b702b46f688bc3ba7f8dc2d35c6eb25482366c4c.zip |
init: fix writepid wrong pid written in file(s)
When child (pid==0) executes fork branch 'pid_str'
will always be 0 writting wrong value to file(s).
Fix by utilizing getpid() to obtain correct pid.
Tracker link provides some insight on why use cases
aren't broken.
Bug: https://code.google.com/p/android/issues/detail?id=200392
Change-Id: I29989365a8bac94502c090918fa30e5cc88eb1ea
Signed-off-by: Anestis Bechtsoudis <anestis@census-labs.com>
-rw-r--r-- | init/service.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/init/service.cpp b/init/service.cpp index 0ddc48485..bdecc324f 100644 --- a/init/service.cpp +++ b/init/service.cpp @@ -416,7 +416,7 @@ bool Service::Start(const std::vector<std::string>& dynamic_args) { } } - std::string pid_str = StringPrintf("%d", pid); + std::string pid_str = StringPrintf("%d", getpid()); for (const auto& file : writepid_files_) { if (!WriteStringToFile(pid_str, file)) { ERROR("couldn't write %s to %s: %s\n", |