Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4d7d903e authored by Elliott Hughes's avatar Elliott Hughes Committed by Gerrit Code Review
Browse files

Merge "init: actually report which signal is causing the reboot."

parents f1933c91 636ebc9b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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();
}

+3 −2
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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
+2 −1
Original line number Diff line number Diff line
@@ -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