console4.txt

来自「linux/kd.h文件中介绍了ioctl函数能够使用的命令」· 文本 代码 · 共 37 行

TXT
37
字号
Example:
	#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;
          long int arg;

          /* To be used as the fd in ioctl(). */
	  if ((fd = open("/dev/console", O_NOCTTY)) == ERROR) {
	     perror("open");
	     exit(ERROR);
	  }

	  printf("w00w00!\n\n");

          if ((ioctl(fd, KDGETMODE, &arg)) == ERROR) {
	     perror("ioctl");
	     close(fd);
	     exit(ERROR);
	  }

          if (arg == KD_TEXT) printf("console in text mode.\n");
          else if (arg == KD_GRAPHICS) 
             printf("console is in graphics mode.\n"); 

	  close(fd);
	}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?