• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/core


Commit MetaInfo

修訂a03feed67d521413b43c2e15edebf363568e5400 (tree)
時間2017-11-21 18:27:46
作者Chih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

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.

Change Summary

差異

--- a/init/init.cpp
+++ b/init/init.cpp
@@ -590,6 +590,19 @@ static void selinux_initialize(bool in_kernel_domain) {
590590 }
591591 }
592592
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+
593606 int main(int argc, char** argv) {
594607 if (strstr(argv[0], "modprobe")) {
595608 return modprobe_main(argc, argv);
@@ -603,6 +616,8 @@ int main(int argc, char** argv) {
603616 return watchdogd_main(argc, argv);
604617 }
605618
619+ install_signal_handlers();
620+
606621 // Clear the umask.
607622 umask(0);
608623