Merge "init: Cleanly shut down subcontext processes"
This commit is contained in:
commit
f6b823141e
3 changed files with 13 additions and 1 deletions
|
|
@ -443,6 +443,7 @@ void DoReboot(unsigned int cmd, const std::string& reason, const std::string& re
|
||||||
for (const auto& s : ServiceList::GetInstance().services_in_shutdown_order()) {
|
for (const auto& s : ServiceList::GetInstance().services_in_shutdown_order()) {
|
||||||
if (!s->IsShutdownCritical()) s->Stop();
|
if (!s->IsShutdownCritical()) s->Stop();
|
||||||
}
|
}
|
||||||
|
SubcontextTerminate();
|
||||||
ReapAnyOutstandingChildren();
|
ReapAnyOutstandingChildren();
|
||||||
|
|
||||||
// 3. send volume shutdown to vold
|
// 3. send volume shutdown to vold
|
||||||
|
|
|
||||||
|
|
@ -352,6 +352,7 @@ Result<std::vector<std::string>> Subcontext::ExpandArgs(const std::vector<std::s
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<Subcontext> subcontexts;
|
static std::vector<Subcontext> subcontexts;
|
||||||
|
static bool shutting_down;
|
||||||
|
|
||||||
std::vector<Subcontext>* InitializeSubcontexts() {
|
std::vector<Subcontext>* InitializeSubcontexts() {
|
||||||
if (SelinuxHasVendorInit()) {
|
if (SelinuxHasVendorInit()) {
|
||||||
|
|
@ -365,12 +366,21 @@ std::vector<Subcontext>* InitializeSubcontexts() {
|
||||||
bool SubcontextChildReap(pid_t pid) {
|
bool SubcontextChildReap(pid_t pid) {
|
||||||
for (auto& subcontext : subcontexts) {
|
for (auto& subcontext : subcontexts) {
|
||||||
if (subcontext.pid() == pid) {
|
if (subcontext.pid() == pid) {
|
||||||
subcontext.Restart();
|
if (!shutting_down) {
|
||||||
|
subcontext.Restart();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SubcontextTerminate() {
|
||||||
|
shutting_down = true;
|
||||||
|
for (auto& subcontext : subcontexts) {
|
||||||
|
kill(subcontext.pid(), SIGTERM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace init
|
} // namespace init
|
||||||
} // namespace android
|
} // namespace android
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ class Subcontext {
|
||||||
int SubcontextMain(int argc, char** argv, const KeywordFunctionMap* function_map);
|
int SubcontextMain(int argc, char** argv, const KeywordFunctionMap* function_map);
|
||||||
std::vector<Subcontext>* InitializeSubcontexts();
|
std::vector<Subcontext>* InitializeSubcontexts();
|
||||||
bool SubcontextChildReap(pid_t pid);
|
bool SubcontextChildReap(pid_t pid);
|
||||||
|
void SubcontextTerminate();
|
||||||
|
|
||||||
} // namespace init
|
} // namespace init
|
||||||
} // namespace android
|
} // namespace android
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue