X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fmain.c;h=5c2af042d9a73937ef310fe271532ba43a9dc7e2;hb=967d86b5cbc39f2b6edeea7ae109dbfcaaf4f006;hp=bba2975e467fea4112bc95a4ba7bd9ad6872310a;hpb=e99e38bbdcca3fe5956823bdb3d38544ccf93221;p=elogind.git diff --git a/src/main.c b/src/main.c index bba2975e4..5c2af042d 100644 --- a/src/main.c +++ b/src/main.c @@ -37,6 +37,7 @@ #include "mount-setup.h" #include "hostname-setup.h" #include "loopback-setup.h" +#include "kmod-setup.h" #include "load-fragment.h" #include "fdset.h" @@ -138,15 +139,10 @@ _noreturn static void crash(int sig) { else if (pid == 0) { int fd, r; - if ((fd = acquire_terminal("/dev/console", false, true)) < 0) { + if ((fd = acquire_terminal("/dev/console", false, true, true)) < 0) log_error("Failed to acquire terminal: %s", strerror(-fd)); - _exit(1); - } - - if ((r = make_stdio(fd)) < 0) { + else if ((r = make_stdio(fd)) < 0) log_error("Failed to duplicate terminal fd: %s", strerror(-r)); - _exit(1); - } execl("/bin/sh", "/bin/sh", NULL); @@ -169,18 +165,13 @@ static void install_crash_handler(void) { sa.sa_handler = crash; sa.sa_flags = SA_NODEFER; - assert_se(sigaction(SIGSEGV, &sa, NULL) == 0); - assert_se(sigaction(SIGILL, &sa, NULL) == 0); - assert_se(sigaction(SIGFPE, &sa, NULL) == 0); - assert_se(sigaction(SIGBUS, &sa, NULL) == 0); - assert_se(sigaction(SIGQUIT, &sa, NULL) == 0); - assert_se(sigaction(SIGABRT, &sa, NULL) == 0); + sigaction_many(&sa, SIGNALS_CRASH_HANLDER, -1); } static int make_null_stdio(void) { int null_fd, r; - if ((null_fd = open("/dev/null", O_RDWR)) < 0) { + if ((null_fd = open("/dev/null", O_RDWR|O_NOCTTY)) < 0) { log_error("Failed to open /dev/null: %m"); return -errno; } @@ -573,8 +564,7 @@ int main(int argc, char *argv[]) { assert_se(reset_all_signal_handlers() == 0); /* If we are init, we can block sigkill. Yay. */ - ignore_signal(SIGKILL); - ignore_signal(SIGPIPE); + ignore_signals(SIGNALS_IGNORE, -1); if (running_as != MANAGER_SESSION) if (parse_proc_cmdline() < 0) @@ -644,6 +634,7 @@ int main(int argc, char *argv[]) { log_debug("systemd running in %s mode.", manager_running_as_to_string(running_as)); if (running_as == MANAGER_INIT) { + kmod_setup(); hostname_setup(); loopback_setup(); }