summaryrefslogtreecommitdiff
path: root/init/builtins.cpp
diff options
context:
space:
mode:
authorTom Cherry <tomcherry@google.com>2019-10-11 13:18:44 -0700
committerTom Cherry <tomcherry@google.com>2019-10-11 13:45:42 -0700
commit0dbfea7b0778bff25a43602e523deae5bb65b114 (patch)
tree108d52a6da321b7bec78f8c7acec47343b0c4de8 /init/builtins.cpp
parent6b0e789a21cfb796a508e3c5507e49a2e8571582 (diff)
init: trigger shutdown directly from builtins
Especially now that property_service is a thread, there may be some delay between when init sets sys.powerctl and when the main thread of init receives this and triggers shutdown. It's possible that outstanding init commands are run during this gap and that is not desirable. Instead, have builtins call TriggerShutdown() directly, so we can be sure that the next action that init runs will be to shutdown the device. Test: reboot works Test: reboot into recovery due to bad /data works Change-Id: I26fb9f4f57f46c7451b8b58187138cfedd6fd9eb
Diffstat (limited to 'init/builtins.cpp')
-rw-r--r--init/builtins.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 42211b2c1..2f2ead006 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -138,7 +138,14 @@ static Result<void> reboot_into_recovery(const std::vector<std::string>& options
if (!write_bootloader_message(options, &err)) {
return Error() << "Failed to set bootloader message: " << err;
}
- property_set("sys.powerctl", "reboot,recovery");
+ // This function should only be reached from init and not from vendor_init, and we want to
+ // immediately trigger reboot instead of relaying through property_service. Older devices may
+ // still have paths that reach here from vendor_init, so we keep the property_set as a fallback.
+ if (getpid() == 1) {
+ TriggerShutdown("reboot,recovery");
+ } else {
+ property_set("sys.powerctl", "reboot,recovery");
+ }
return {};
}