diff options
author | Treehugger Robot | 2018-07-27 21:30:22 -0500 |
---|---|---|
committer | Gerrit Code Review | 2018-07-27 21:30:22 -0500 |
commit | f6b823141eb5dcb0cdc387ee376a7414d27c3819 (patch) | |
tree | a12bb42c3c2783fbdddd12aefae11b608dcbd5aa /init | |
parent | d81c4f07fb6b9472df64900aedba67549bda11e5 (diff) | |
parent | 92c49bcb3098050d41dd32a782a97cbd7a88675a (diff) | |
download | platform-system-core-f6b823141eb5dcb0cdc387ee376a7414d27c3819.tar.gz platform-system-core-f6b823141eb5dcb0cdc387ee376a7414d27c3819.tar.xz platform-system-core-f6b823141eb5dcb0cdc387ee376a7414d27c3819.zip |
Merge "init: Cleanly shut down subcontext processes"
Diffstat (limited to 'init')
-rw-r--r-- | init/reboot.cpp | 1 | ||||
-rw-r--r-- | init/subcontext.cpp | 12 | ||||
-rw-r--r-- | init/subcontext.h | 1 |
3 files changed, 13 insertions, 1 deletions
diff --git a/init/reboot.cpp b/init/reboot.cpp index 6f6e39f25..11507f489 100644 --- a/init/reboot.cpp +++ b/init/reboot.cpp | |||
@@ -443,6 +443,7 @@ void DoReboot(unsigned int cmd, const std::string& reason, const std::string& re | |||
443 | for (const auto& s : ServiceList::GetInstance().services_in_shutdown_order()) { | 443 | for (const auto& s : ServiceList::GetInstance().services_in_shutdown_order()) { |
444 | if (!s->IsShutdownCritical()) s->Stop(); | 444 | if (!s->IsShutdownCritical()) s->Stop(); |
445 | } | 445 | } |
446 | SubcontextTerminate(); | ||
446 | ReapAnyOutstandingChildren(); | 447 | ReapAnyOutstandingChildren(); |
447 | 448 | ||
448 | // 3. send volume shutdown to vold | 449 | // 3. send volume shutdown to vold |
diff --git a/init/subcontext.cpp b/init/subcontext.cpp index 267d530f0..ee7251328 100644 --- a/init/subcontext.cpp +++ b/init/subcontext.cpp | |||
@@ -352,6 +352,7 @@ Result<std::vector<std::string>> Subcontext::ExpandArgs(const std::vector<std::s | |||
352 | } | 352 | } |
353 | 353 | ||
354 | static std::vector<Subcontext> subcontexts; | 354 | static std::vector<Subcontext> subcontexts; |
355 | static bool shutting_down; | ||
355 | 356 | ||
356 | std::vector<Subcontext>* InitializeSubcontexts() { | 357 | std::vector<Subcontext>* InitializeSubcontexts() { |
357 | if (SelinuxHasVendorInit()) { | 358 | if (SelinuxHasVendorInit()) { |
@@ -365,12 +366,21 @@ std::vector<Subcontext>* InitializeSubcontexts() { | |||
365 | bool SubcontextChildReap(pid_t pid) { | 366 | bool SubcontextChildReap(pid_t pid) { |
366 | for (auto& subcontext : subcontexts) { | 367 | for (auto& subcontext : subcontexts) { |
367 | if (subcontext.pid() == pid) { | 368 | if (subcontext.pid() == pid) { |
368 | subcontext.Restart(); | 369 | if (!shutting_down) { |
370 | subcontext.Restart(); | ||
371 | } | ||
369 | return true; | 372 | return true; |
370 | } | 373 | } |
371 | } | 374 | } |
372 | return false; | 375 | return false; |
373 | } | 376 | } |
374 | 377 | ||
378 | void SubcontextTerminate() { | ||
379 | shutting_down = true; | ||
380 | for (auto& subcontext : subcontexts) { | ||
381 | kill(subcontext.pid(), SIGTERM); | ||
382 | } | ||
383 | } | ||
384 | |||
375 | } // namespace init | 385 | } // namespace init |
376 | } // namespace android | 386 | } // namespace android |
diff --git a/init/subcontext.h b/init/subcontext.h index 22d7d43bd..628fd50e7 100644 --- a/init/subcontext.h +++ b/init/subcontext.h | |||
@@ -63,6 +63,7 @@ class Subcontext { | |||
63 | int SubcontextMain(int argc, char** argv, const KeywordFunctionMap* function_map); | 63 | int SubcontextMain(int argc, char** argv, const KeywordFunctionMap* function_map); |
64 | std::vector<Subcontext>* InitializeSubcontexts(); | 64 | std::vector<Subcontext>* InitializeSubcontexts(); |
65 | bool SubcontextChildReap(pid_t pid); | 65 | bool SubcontextChildReap(pid_t pid); |
66 | void SubcontextTerminate(); | ||
66 | 67 | ||
67 | } // namespace init | 68 | } // namespace init |
68 | } // namespace android | 69 | } // namespace android |