system/core
修訂 | a03feed67d521413b43c2e15edebf363568e5400 (tree) |
---|---|
時間 | 2017-11-21 18:27:46 |
作者 | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
init: handle ctrl-alt-del event
By setting /proc/sys/kernel/ctrl-alt-del to 1, kernel will trap
ctrl-alt-del event and send a SIGINT signal to init.
Start the ctrl-alt-del service on receiving the signal.
@@ -590,6 +590,19 @@ static void selinux_initialize(bool in_kernel_domain) { | ||
590 | 590 | } |
591 | 591 | } |
592 | 592 | |
593 | +static void install_signal_handlers() | |
594 | +{ | |
595 | + struct sigaction action; | |
596 | + memset(&action, 0, sizeof(action)); | |
597 | + sigfillset(&action.sa_mask); | |
598 | + action.sa_flags = SA_RESTART; | |
599 | + action.sa_handler = [](int sig) { | |
600 | + NOTICE("Got ctrl-alt-del: %d", sig); | |
601 | + handle_control_message("start", "ctrl-alt-del"); | |
602 | + }; | |
603 | + sigaction(SIGINT, &action, nullptr); | |
604 | +} | |
605 | + | |
593 | 606 | int main(int argc, char** argv) { |
594 | 607 | if (strstr(argv[0], "modprobe")) { |
595 | 608 | return modprobe_main(argc, argv); |
@@ -603,6 +616,8 @@ int main(int argc, char** argv) { | ||
603 | 616 | return watchdogd_main(argc, argv); |
604 | 617 | } |
605 | 618 | |
619 | + install_signal_handlers(); | |
620 | + | |
606 | 621 | // Clear the umask. |
607 | 622 | umask(0); |
608 | 623 |