aboutsummaryrefslogtreecommitdiffstats
path: root/vt.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2019-01-31 10:49:31 +0100
committerGerd Hoffmann <kraxel@redhat.com>2019-01-31 10:49:31 +0100
commit620c38f6f45a8708d9dd82f638beb06789b6c7d1 (patch)
tree79629772daacf0be6a40fd562d564bde8231ae7b /vt.c
parent7fcf29ed3f77f60873bad160d5afac498746d6d8 (diff)
downloadfbida-620c38f6f45a8708d9dd82f638beb06789b6c7d1.tar.gz
drop -vt option
Diffstat (limited to 'vt.c')
-rw-r--r--vt.c44
1 files changed, 9 insertions, 35 deletions
diff --git a/vt.c b/vt.c
index 55ef71f..4a9c3e1 100644
--- a/vt.c
+++ b/vt.c
@@ -31,7 +31,7 @@ static bool console_switching_active;
static int kd_mode;
static struct vt_mode vt_mode;
static struct vt_mode vt_omode;
-static int orig_vt_no = 0;
+static int orig_vt_no = -1;
static void (*console_redraw)(void);
static void console_switch_signal(int signal)
@@ -148,43 +148,16 @@ int check_console_switch(void)
return 1;
}
-void console_set_vt(int vtno)
+int console_aquire_vt(void)
{
struct vt_stat vts;
- char vtname[12];
+ int vtno = -1;
- if (vtno < 0) {
- if (-1 == ioctl(STDIN_FILENO, VT_OPENQRY, &vtno) || vtno == -1) {
- perror("ioctl VT_OPENQRY");
- exit(1);
- }
- }
-
- vtno &= 0xff;
- sprintf(vtname, "/dev/tty%d", vtno);
- chown(vtname, getuid(), getgid());
- if (-1 == access(vtname, R_OK | W_OK)) {
- fprintf(stderr,"access %s: %s\n",vtname,strerror(errno));
- exit(1);
- }
-
- /* switch controlling tty */
- switch (fork()) {
- case 0:
- break;
- case -1:
- perror("fork");
- exit(1);
- default:
- exit(0);
+ if (-1 == ioctl(STDIN_FILENO, VT_OPENQRY, &vtno) || vtno == -1) {
+ perror("ioctl VT_OPENQRY");
+ return -1;
}
- close(0);
- close(1);
- close(2);
- setsid();
- open(vtname,O_RDWR);
- dup(0);
- dup(0);
+ fprintf(stderr, "using vt %d\n", vtno);
if (-1 == ioctl(STDIN_FILENO,VT_GETSTATE, &vts)) {
perror("ioctl VT_GETSTATE");
@@ -199,11 +172,12 @@ void console_set_vt(int vtno)
perror("ioctl VT_WAITACTIVE");
exit(1);
}
+ return 0;
}
void console_restore_vt(void)
{
- if (!orig_vt_no)
+ if (orig_vt_no < 0)
return;
if (ioctl(STDIN_FILENO, VT_ACTIVATE, orig_vt_no) < 0)