From d3e94f8422a720471ccc546094991a3493b205dc Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Thu, 27 Jan 2022 17:24:34 +0100 Subject: linux: take over ctrl-alt-del handling when reasonable --- rvnit.c | 16 ++++++++++++---- 1 file 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) { -- cgit 1.4.1