src/util.{c,h}: get rid of ensure_* functions
[vlock.git] / modules / all.c
blobf0d11894440dcee6ff838be15454a05270696b41
1 /* all.c -- console grabbing plugin 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 <string.h>
17 #include <unistd.h>
18 #include <fcntl.h>
19 #include <sys/ioctl.h>
20 #include <errno.h>
21 #include <signal.h>
23 #include "vlock_plugin.h"
24 #include "console_switch.h"
26 bool vlock_start(void __attribute__((unused)) **ctx_ptr)
28 if (!lock_console_switch()) {
29 if (!lock_console_switch()) {
30 if (errno == ENOTTY || errno == EINVAL)
31 fprintf(stderr, "vlock-all: this terminal is not a virtual console\n");
32 else
33 fprintf(stderr, "vlock-all: could not disable console switching: %s\n", strerror(errno));
37 return console_switch_locked;
40 bool vlock_end(void __attribute__((unused)) **ctx_ptr)
42 return unlock_console_switch();