📄 console16.txt
字号:
Example:
This will not work, sorry. But included as an example anyway. If
anyone knows why this will not work, please let me know. I saw no
indications as to why from following the signals in
linux/kernel/exit.c, but it is possible I missed something.
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>
#include <sys/stat.h>
#include <linux/kd.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#define ERROR -1
void main()
{
int fd;
int signum = 2; /* Signal to accept keyboard input for. */
/* SIGINT == 2 */
if ((fd = open("/dev/console", O_NOCTTY)) == ERROR) {
perror("open");
exit(ERROR);
}
printf("w00w00!\n\n");
printf("Ignoring SIGINT (Ctrl-C) before call to ioctl().\n");
signal(SIGINT, SIG_IGN);
if (ioctl(fd, KDSIGACCEPT, signum) == ERROR) {
perror("ioctl");
close(fd);
exit(ERROR);
}
printf("Signal is now being accepted. "
"Try aborting with Ctrl-C (this does not work). Hit enter.\n");
getchar();
printf("Well, you were supposed to abort rather than hit Enter.\n");
close(fd);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -