From 161b8626bdae56350486feeb455865adf32b952a Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Tue, 26 Sep 2017 08:26:12 -0700 Subject: [PATCH] init: report shutdown,container for sigterm of init Change HandleSigtermSignal() handler to report shutdown,container. Add the new reason to bootstat. Remove log stutter as HandlPowerctlMessage will also do a LOG(INFO) reporting shutdown,container as reason. Sending SIGTERM to init is to allow a host OS to ask an Android Container instance to shutdown. The temptation is to report shutdown,sigterm but that does not accurately describe the usage scenario. Test: compile Bug: 63736262 Change-Id: I3c5798921bdbef5d2689ad22a2e8103741b570b4 --- bootstat/bootstat.cpp | 1 + init/init.cpp | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bootstat/bootstat.cpp b/bootstat/bootstat.cpp index 7c0b15ead..17986b9e3 100644 --- a/bootstat/bootstat.cpp +++ b/bootstat/bootstat.cpp @@ -204,6 +204,7 @@ const std::map kBootReasonMap = { {"reboot,shell", 66}, {"reboot,adb", 67}, {"reboot,userrequested", 68}, + {"shutdown,container", 69}, // Host OS asking Android Container to shutdown }; // Converts a string value representing the reason the system booted to an diff --git a/init/init.cpp b/init/init.cpp index 817b33e75..dbe833f1a 100644 --- a/init/init.cpp +++ b/init/init.cpp @@ -417,8 +417,7 @@ static void HandleSigtermSignal() { return; } - LOG(INFO) << "Handling SIGTERM, shutting system down"; - HandlePowerctlMessage("shutdown"); + HandlePowerctlMessage("shutdown,container"); } static void InstallSigtermHandler() {