summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2022-01-27 17:24:34 +0100
committerLeah Neukirchen <leah@vuxu.org>2022-01-27 17:24:34 +0100
commitd3e94f8422a720471ccc546094991a3493b205dc (patch)
treebd6dbacce9db3cd92ffafa954f3ca71b0ad01092
parent8788bf0fbfdd98c82fd899658d363f34d38be47e (diff)
downloadrvnit-d3e94f8422a720471ccc546094991a3493b205dc.tar.gz
rvnit-d3e94f8422a720471ccc546094991a3493b205dc.tar.xz
rvnit-d3e94f8422a720471ccc546094991a3493b205dc.zip
linux: take over ctrl-alt-del handling when reasonable
-rw-r--r--rvnit.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/rvnit.c b/rvnit.c
index d8fcd56..75b55d5 100644
--- a/rvnit.c
+++ b/rvnit.c
@@ -716,6 +716,14 @@ main(int argc, char *argv[])
 	if (pid1)
 		ioctl(0, TIOCNOTTY);
 
+	sigset_t emptyset;
+	sigemptyset(&emptyset);
+	sigaction(SIGINT,
+	    &(struct sigaction){ .sa_handler=on_sigint, .sa_mask=emptyset }, 0);
+
+#ifdef __linux__
+	reboot(RB_DISABLE_CAD);
+#endif
 
 	int i;
 	for (level = 0; level < 100; level++) {
@@ -800,10 +808,6 @@ cont1:
 		}
 	}
 
-	sigset_t emptyset;
-	sigemptyset(&emptyset);
-	sigaction(SIGINT,
-	    &(struct sigaction){ .sa_handler=on_sigint, .sa_mask=emptyset }, 0);
 	sigaction(SIGCONT,
 	    &(struct sigaction){ .sa_handler=on_sigcont, .sa_mask=emptyset }, 0);
 
@@ -895,6 +899,10 @@ cont2:
 	if (pid1)
 		own_console();
 
+#ifdef __linux__
+	reboot(RB_ENABLE_CAD);
+#endif
+
 	LOG("shutting down");
 
 	if (want_reboot) {