X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=main.c;h=802e2ae9f33d1d518460c315b1391c35356b79a5;hp=0eb64d265928e918b61e0797ebd825ed0b365ae6;hb=5e7ee61c1a2b45c1006336f22ded8e099d155270;hpb=80876c20f64f87765242bc35895977ab6a855729 diff --git a/main.c b/main.c index 0eb64d265..802e2ae9f 100644 --- a/main.c +++ b/main.c @@ -110,9 +110,19 @@ _noreturn static void crash(int sig) { chvt(crash_chvt); if (crash_shell) { + sigset_t mask; + log_info("Executing crash shell in 10s..."); sleep(10); + /* Make sure the signal is not delivered inside the + * exec() */ + assert_se(sigemptyset(&mask) == 0); + assert_se(sigaddset(&mask, sig) == 0); + assert_se(sigprocmask(SIG_SETMASK, &mask, NULL) == 0); + + ignore_signal(sig); + execl("/bin/sh", "/bin/sh", NULL); log_error("execl() failed: %s", strerror(errno)); } @@ -240,6 +250,15 @@ static int parse_proc_cmdline_word(const char *word) { else crash_shell = r; + + } else if (startswith(word, "systemd.confirm_spawn=")) { + int r; + + if ((r = parse_boolean(word + 22)) < 0) + log_warning("Failed to parse confirm spawn switch %s, Ignoring.", word + 22); + else + confirm_spawn = r; + } else if (startswith(word, "systemd.crash_chvt=")) { int k; @@ -259,6 +278,7 @@ static int parse_proc_cmdline_word(const char *word) { log_info("systemd.dump_core=0|1 Dump core on crash"); log_info("systemd.crash_shell=0|1 On crash run shell"); log_info("systemd.crash_chvt=N Change to VT #N on crash"); + log_info("systemd.confirm_spawn=0|1 Confirm every process spawn"); } else { unsigned i; @@ -445,8 +465,8 @@ int main(int argc, char *argv[]) { assert_se(reset_all_signal_handlers() == 0); /* If we are init, we can block sigkill. Yay. */ - signal(SIGKILL, SIG_IGN); - signal(SIGPIPE, SIG_IGN); + ignore_signal(SIGKILL); + ignore_signal(SIGPIPE); /* Close all open files */ assert_se(close_all_fds(NULL, 0) == 0); @@ -567,5 +587,8 @@ finish: dbus_shutdown(); + if (getpid() == 1) + freeze(); + return retval; }