The Linux kernel can either hard reboot or send SIGINT the init process upon Ctrl + Alt + Del
The Linux kernel itself allows two possible behaviors from Ctrl-Alt-Del:
- reboot immediately
- send SIGINT to the init process
Which behavior is used can be selected with either:
reboot system call, see man 2 reboot
/proc/sys/kernel/ctrl-alt-del
Therefore, if the SIGINT behaviour is enabled, then the outcome of Ctrl + Alt + Del depends entirely on the SIGINT handler that your init has.
For example, BusyBox' 1.28.3 init execs an arbitrary command given in /etc/inittab as:
::ctrlaltdel:/sbin/reboot
And here is a minimal interesting C example for uclibc:
#define _XOPEN_SOURCE 700
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/reboot.h>
#include <unistd.h>
void signal_handler(int sig) {
write(STDOUT_FILENO, "cad\n", 4);
signal(sig, signal_handler);
}
int main(void) {
int i = 0;
/* Disable the forced reboot, enable sending SIGINT to init. */
reboot(RB_DISABLE_CAD);
signal(SIGINT, signal_handler);
while (1) {
sleep(1);
printf("%d\n", i);
i++;
}
return EXIT_SUCCESS;
}
Here is an easy setup to try this out.