src/util.{c,h}: fatal_perror
[vlock.git] / modules / all.c
blob937b6d989de76853e5623f5bd172e71a03156e8e
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 char *error = NULL;
30 if (!lock_console_switch(&error)) {
31 if (error != NULL) {
32 fprintf(stderr, "vlock-all: %s\n", error);
33 free(error);
34 } else {
35 fprintf(stderr, "vlock-all: could not disable console switching\n");
39 return console_switch_locked;
42 bool vlock_end(void __attribute__((unused)) **ctx_ptr)
44 unlock_console_switch();
45 return true;