Merge "init: actually report which signal is causing the reboot."
This commit is contained in:
commit
4d7d903e2b
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
|
// reboot_utils.h
|
||||||
inline void SetFatalRebootTarget() {}
|
inline void SetFatalRebootTarget() {}
|
||||||
inline void __attribute__((noreturn)) InitFatalReboot() {
|
inline void __attribute__((noreturn)) InitFatalReboot(int signal_number) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ void __attribute__((noreturn)) RebootSystem(unsigned int cmd, const std::string&
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
void __attribute__((noreturn)) InitFatalReboot() {
|
void __attribute__((noreturn)) InitFatalReboot(int signal_number) {
|
||||||
auto pid = fork();
|
auto pid = fork();
|
||||||
|
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
|
|
@ -124,6 +124,7 @@ void __attribute__((noreturn)) InitFatalReboot() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// In the parent, let's try to get a backtrace then shutdown.
|
// In the parent, let's try to get a backtrace then shutdown.
|
||||||
|
LOG(ERROR) << __FUNCTION__ << ": signal " << signal_number;
|
||||||
std::unique_ptr<Backtrace> backtrace(
|
std::unique_ptr<Backtrace> backtrace(
|
||||||
Backtrace::Create(BACKTRACE_CURRENT_PROCESS, BACKTRACE_CURRENT_THREAD));
|
Backtrace::Create(BACKTRACE_CURRENT_PROCESS, BACKTRACE_CURRENT_THREAD));
|
||||||
if (!backtrace->Unwind(0)) {
|
if (!backtrace->Unwind(0)) {
|
||||||
|
|
@ -154,7 +155,7 @@ void InstallRebootSignalHandlers() {
|
||||||
// RebootSystem uses syscall() which isn't actually async-signal-safe, but our only option
|
// 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
|
// and probably good enough given this is already an error case and only enabled for
|
||||||
// development builds.
|
// development builds.
|
||||||
InitFatalReboot();
|
InitFatalReboot(signal);
|
||||||
};
|
};
|
||||||
action.sa_flags = SA_RESTART;
|
action.sa_flags = SA_RESTART;
|
||||||
sigaction(SIGABRT, &action, nullptr);
|
sigaction(SIGABRT, &action, nullptr);
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ void SetFatalRebootTarget();
|
||||||
bool IsRebootCapable();
|
bool IsRebootCapable();
|
||||||
// This is a wrapper around the actual reboot calls.
|
// This is a wrapper around the actual reboot calls.
|
||||||
void __attribute__((noreturn)) RebootSystem(unsigned int cmd, const std::string& reboot_target);
|
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();
|
void InstallRebootSignalHandlers();
|
||||||
|
|
||||||
} // namespace init
|
} // namespace init
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
#include <signal.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
@ -481,7 +482,7 @@ static void InitAborter(const char* abort_message) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
InitFatalReboot();
|
InitFatalReboot(SIGABRT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The kernel opens /dev/console and uses that fd for stdin/stdout/stderr if there is a serial
|
// The kernel opens /dev/console and uses that fd for stdin/stdout/stderr if there is a serial
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue