diff options
| author | Tom Cherry <tomcherry@google.com> | 2017-08-28 21:45:38 +0000 |
|---|---|---|
| committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-08-28 21:45:38 +0000 |
| commit | 30bf4b75003a6ca3e290be71ec87545bea82c760 (patch) | |
| tree | 0cfd7245bc87da1f049200b46bf47809529ca906 /init/init.cpp | |
| parent | 32d2eae8b91d1316dc3c8c3890dc0d60c4cb716d (diff) | |
| parent | 1ca83249a1748c2458664afa76962e2bb9cdb553 (diff) | |
| download | system_core-30bf4b75003a6ca3e290be71ec87545bea82c760.tar.gz system_core-30bf4b75003a6ca3e290be71ec87545bea82c760.tar.bz2 system_core-30bf4b75003a6ca3e290be71ec87545bea82c760.zip | |
Merge "init: fix signal handling and LOG(FATAL) in child processes"
Diffstat (limited to 'init/init.cpp')
| -rw-r--r-- | init/init.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/init/init.cpp b/init/init.cpp index 4a8459f1d..678f49f58 100644 --- a/init/init.cpp +++ b/init/init.cpp @@ -358,7 +358,7 @@ static void set_usb_controller() { } } -static void install_reboot_signal_handlers() { +static void InstallRebootSignalHandlers() { // Instead of panic'ing the kernel as is the default behavior when init crashes, // we prefer to reboot to bootloader on development builds, as this will prevent // boot looping bad configurations and allow both developers and test farms to easily @@ -366,7 +366,13 @@ static void install_reboot_signal_handlers() { struct sigaction action; memset(&action, 0, sizeof(action)); sigfillset(&action.sa_mask); - action.sa_handler = [](int) { + action.sa_handler = [](int signal) { + // These signal handlers are also caught for processes forked from init, however we do not + // want them to trigger reboot, so we directly call _exit() for children processes here. + if (getpid() != 1) { + _exit(signal); + } + // Calling DoReboot() or LOG(FATAL) is not a good option as this is a signal handler. // 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 @@ -396,7 +402,7 @@ int main(int argc, char** argv) { } if (REBOOT_BOOTLOADER_ON_PANIC) { - install_reboot_signal_handlers(); + InstallRebootSignalHandlers(); } bool is_first_stage = (getenv("INIT_SECOND_STAGE") == nullptr); |
