[go: up one dir, main page]

File: chvt.c

package info (click to toggle)
console-tools 1998.08.11-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 5,240 kB
  • ctags: 805
  • sloc: ansic: 8,241; sh: 2,947; yacc: 970; makefile: 356; lex: 287; pascal: 192; perl: 110
file content (39 lines) | stat: -rw-r--r-- 712 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * chvt.c - aeb - 940227 - Change virtual terminal
 */
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <linux/vt.h>

#include <lct/local.h>
#include <lct/utils.h>
#include <lct/console.h>

int main(int argc, char *argv[]) 
{
  int fd, num;
  
  if (argc != 2) 
    {
      fprintf(stderr, "Usage: %s vt_number\n",
	      strip_path(argv[0]));
      exit(1);
    }
  if (-1 == (fd = get_console_fd(NULL))) exit (1);
  
  num = atoi(argv[1]);
  if (ioctl(fd,VT_ACTIVATE,num)) 
    {
      perror("chvt: VT_ACTIVATE");
      exit(1);
    }
  if (ioctl(fd,VT_WAITACTIVE,num)) 
    {
      perror("VT_WAITACTIVE");
      exit(1);
    }
  exit(0);
}