OSDN Git Service

init: handle ctrl-alt-del event
authorChih-Wei Huang <cwhuang@linux.org.tw>
Mon, 20 Nov 2017 08:50:20 +0000 (16:50 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Tue, 17 Dec 2019 05:24:56 +0000 (13:24 +0800)
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.

init/reboot_utils.cpp

index de085cc..cf2ac4a 100644 (file)
@@ -29,6 +29,7 @@
 #include <cutils/android_reboot.h>
 
 #include "capabilities.h"
+#include "init.h"
 
 namespace android {
 namespace init {
@@ -167,6 +168,12 @@ void InstallRebootSignalHandlers() {
 #endif
     sigaction(SIGSYS, &action, nullptr);
     sigaction(SIGTRAP, &action, nullptr);
+
+    action.sa_handler = [](int sig) {
+        LOG(INFO) << "Got ctrl-alt-del: " << sig;
+        HandleControlMessage("start", "ctrl-alt-del", getpid());
+    };
+    sigaction(SIGINT, &action, nullptr);
 }
 
 }  // namespace init