readme: create Ctrl-Alt-Del and improve SysRq

This commit is contained in:
Ciro Santilli
2018-05-20 15:32:44 +01:00
parent 9cec69df1e
commit 2ecc6dadb4
3 changed files with 148 additions and 3 deletions

View File

@@ -0,0 +1,24 @@
#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;
}

View File

@@ -2,6 +2,7 @@
* https://stackoverflow.com/questions/28812514/how-to-shutdown-linux-using-c-or-qt-without-call-to-system
**/
#define _XOPEN_SOURCE 700
#include <stdio.h>
#include <sys/reboot.h>
#include <unistd.h>