init: actually report which signal is causing the reboot.
It wasn't clear to me why init was rebooting until I saw that it was SIGABRT, which then made me read through earlier log spam to work out what was actually unhappy (the SELinux compiler, in my case). Test: worked out why init was rebooting my device Change-Id: I605d8956213c4c23711073fd4b0ff99562b7f351
This commit is contained in:
parent
d0accefc05
commit
636ebc9b3b
4 changed files with 7 additions and 5 deletions
|
@ -55,7 +55,7 @@ inline uint32_t HandlePropertySet(const std::string&, const std::string&, const
|
|||
|
||||
// reboot_utils.h
|
||||
inline void SetFatalRebootTarget() {}
|
||||
inline void __attribute__((noreturn)) InitFatalReboot() {
|
||||
inline void __attribute__((noreturn)) InitFatalReboot(int signal_number) {
|
||||
abort();
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ void __attribute__((noreturn)) RebootSystem(unsigned int cmd, const std::string&
|
|||
abort();
|
||||
}
|
||||
|
||||
void __attribute__((noreturn)) InitFatalReboot() {
|
||||
void __attribute__((noreturn)) InitFatalReboot(int signal_number) {
|
||||
auto pid = fork();
|
||||
|
||||
if (pid == -1) {
|
||||
|
@ -124,6 +124,7 @@ void __attribute__((noreturn)) InitFatalReboot() {
|
|||
}
|
||||
|
||||
// In the parent, let's try to get a backtrace then shutdown.
|
||||
LOG(ERROR) << __FUNCTION__ << ": signal " << signal_number;
|
||||
std::unique_ptr<Backtrace> backtrace(
|
||||
Backtrace::Create(BACKTRACE_CURRENT_PROCESS, BACKTRACE_CURRENT_THREAD));
|
||||
if (!backtrace->Unwind(0)) {
|
||||
|
@ -154,7 +155,7 @@ void InstallRebootSignalHandlers() {
|
|||
// RebootSystem uses syscall() which isn't actually async-signal-safe, but our only option
|
||||
// and probably good enough given this is already an error case and only enabled for
|
||||
// development builds.
|
||||
InitFatalReboot();
|
||||
InitFatalReboot(signal);
|
||||
};
|
||||
action.sa_flags = SA_RESTART;
|
||||
sigaction(SIGABRT, &action, nullptr);
|
||||
|
|
|
@ -27,7 +27,7 @@ void SetFatalRebootTarget();
|
|||
bool IsRebootCapable();
|
||||
// This is a wrapper around the actual reboot calls.
|
||||
void __attribute__((noreturn)) RebootSystem(unsigned int cmd, const std::string& reboot_target);
|
||||
void __attribute__((noreturn)) InitFatalReboot();
|
||||
void __attribute__((noreturn)) InitFatalReboot(int signal_number);
|
||||
void InstallRebootSignalHandlers();
|
||||
|
||||
} // namespace init
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <pwd.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -481,7 +482,7 @@ static void InitAborter(const char* abort_message) {
|
|||
return;
|
||||
}
|
||||
|
||||
InitFatalReboot();
|
||||
InitFatalReboot(SIGABRT);
|
||||
}
|
||||
|
||||
// The kernel opens /dev/console and uses that fd for stdin/stdout/stderr if there is a serial
|
||||
|
|
Loading…
Reference in a new issue