- 论坛徽章:
- 0
|
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/ioctl.h>
int main(int argc, char **argv)
{
char bytes[2] = {11,0}; /* 11 is the TIOCLINUX cmd number */
if (argc==2) bytes[1] = atoi(argv[1]); /* the chosen console */
else {
fprintf(stderr, "%s: need a single arg\n",argv[0]); exit(1);
}
if (ioctl(STDIN_FILENO, TIOCLINUX, bytes)<0) { /* use stdin */
fprintf(stderr,"%s: ioctl(stdin, TIOCLINUX): %s\n",
argv[0], strerror(errno));
exit(1);
}
exit(0);
}
内核可以将消息发送到指定的虚拟控制台
上面的程序应该就是来实现该目的的吧,但是编译完后如何运行呢?
说是要在调用时候附加一个参数指定要接收的控制台编号 但是我每次运行都是显示无效参数 要如何运行呢? |
|