console19.txt
来自「linux/kd.h文件中介绍了ioctl函数能够使用的命令」· 文本 代码 · 共 49 行
TXT
49 行
Example:
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <linux/vt.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#define ERROR -1
void main()
{
int fd;
struct vt_mode mode;
if ((fd = open("/dev/console", O_NOCTTY)) == ERROR) {
perror("open");
exit(ERROR);
}
printf("w00w00!\n\n");
if (ioctl(fd, VT_GETMODE, &mode) == ERROR) {
perror("ioctl");
close(fd);
exit(ERROR);
}
printf("Modes of active VT:\n");
if (mode.mode == VT_AUTO) printf("Automatic VT switching\n");
else if (mode.mode == VT_PROCESS)
printf("Process controls switching.\n");
else if (mode.mode == VT_ACKACQ)
printf("Acknowledgement of switches.\n");
else printf("mode == %d\n", mode.mode);
if (mode.waitv) printf("Will wait on writes if not active.\n");
else printf("Will not wait on writes even when not active.\n");
printf("Signal number to release on release request: %d\n",
mode.relsig);
printf("Signal number to raise on acquisition: %d\n",
mode.acqsig);
close(fd);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?