it is wrong to use /dev/console, use /dev/tty0 instead
[vlock.git] / vlock-lockswitch.c
blobc3291f252098b4fad237711b2abd5141d677a7ce
1 /* vlock-lockswitch.c -- console switch locking routine for vlock,
2 * the VT locking program for linux
4 * This program is copyright (C) 2007 Frank Benkstein, and is free
5 * software which is freely distributable under the terms of the
6 * GNU General Public License version 2, included as the file COPYING in this
7 * distribution. It is NOT public domain software, and any
8 * redistribution not permitted by the GNU General Public License is
9 * expressly forbidden without prior written permission from
10 * the author.
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <sys/types.h>
17 #include <sys/stat.h>
18 #include <fcntl.h>
19 #include <sys/ioctl.h>
20 #include <sys/vt.h>
22 #define CONSOLE "/dev/tty0"
24 int main(void) {
25 int consfd;
27 if ((consfd = open(CONSOLE, O_RDWR)) < 0) {
28 perror("vlock: cannot open virtual console");
29 exit (1);
32 /* globally disable virtual console switching */
33 if (ioctl(consfd, VT_LOCKSWITCH) < 0) {
34 perror("vlock-lockswitch: could not disable console switching");
35 exit (1);
38 return 0;