aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenny Levinsen <kl@kl.wtf>2020-09-22 01:00:18 +0200
committerKenny Levinsen <kl@kl.wtf>2020-09-22 01:14:24 +0200
commitbe45c480ec0792c7dfb97e39b4f5369b75593ae8 (patch)
treee7d8a7e18d45269db06b55427a4b7ca5d7d23e19
parentba4c4226595598f6e3f9712eed6c04c49b7399e5 (diff)
terminal: Ack both release and acquire
Linux only requires acking release and ignores ack of acquire, but FreeBSD is more stringent and will patiently wait for both to be acked. Implement proper acking for both events.
-rw-r--r--common/terminal.c18
-rw-r--r--include/seat.h2
-rw-r--r--include/terminal.h3
-rw-r--r--seatd/seat.c20
-rw-r--r--seatd/server.c2
5 files changed, 30 insertions, 15 deletions
diff --git a/common/terminal.c b/common/terminal.c
index ad54624..7e4088d 100644
--- a/common/terminal.c
+++ b/common/terminal.c
@@ -199,7 +199,7 @@ int terminal_set_process_switching(int fd, bool enable) {
}
int terminal_switch_vt(int fd, int vt) {
- log_debugf("switching to vt %d", vt);
+ log_debugf("switching to VT %d", vt);
if (ioctl(fd, VT_ACTIVATE, vt) == -1) {
log_errorf("could not activate VT: %s", strerror(errno));
return -1;
@@ -208,10 +208,20 @@ int terminal_switch_vt(int fd, int vt) {
return 0;
}
-int terminal_ack_switch(int fd) {
- log_debug("acking vt switch");
+int terminal_ack_release(int fd) {
+ log_debug("acking VT release");
+ if (ioctl(fd, VT_RELDISP, 1) == -1) {
+ log_errorf("could not ack VT release: %s", strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
+
+int terminal_ack_acquire(int fd) {
+ log_debug("acking VT acquire");
if (ioctl(fd, VT_RELDISP, VT_ACKACQ) == -1) {
- log_errorf("could not ack VT switch: %s", strerror(errno));
+ log_errorf("could not ack VT acquire: %s", strerror(errno));
return -1;
}
diff --git a/include/seat.h b/include/seat.h
index 2d269cc..cc21b7f 100644
--- a/include/seat.h
+++ b/include/seat.h
@@ -53,6 +53,6 @@ struct seat_device *seat_find_device(struct client *client, int device_id);
int seat_set_next_session(struct client *client, int session);
int seat_vt_activate(struct seat *seat);
-int seat_prepare_vt_switch(struct seat *seat);
+int seat_vt_release(struct seat *seat);
#endif
diff --git a/include/terminal.h b/include/terminal.h
index 1215d8b..fb46ce3 100644
--- a/include/terminal.h
+++ b/include/terminal.h
@@ -8,7 +8,8 @@ int terminal_open(int vt);
int terminal_set_process_switching(int fd, bool enable);
int terminal_current_vt(int fd);
int terminal_switch_vt(int fd, int vt);
-int terminal_ack_switch(int fd);
+int terminal_ack_release(int fd);
+int terminal_ack_acquire(int fd);
int terminal_set_keyboard(int fd, bool enable);
int terminal_set_graphics(int fd, bool enable);
diff --git a/seatd/seat.c b/seatd/seat.c
index 16935cf..1ce44d0 100644
--- a/seatd/seat.c
+++ b/seatd/seat.c
@@ -99,13 +99,17 @@ static int vt_switch(struct seat *seat, int vt) {
return 0;
}
-static int vt_ack(struct seat *seat) {
+static int vt_ack(struct seat *seat, bool release) {
int tty0fd = terminal_open(seat->cur_vt);
if (tty0fd == -1) {
log_errorf("unable to open tty0: %s", strerror(errno));
return -1;
}
- terminal_ack_switch(tty0fd);
+ if (release) {
+ terminal_ack_release(tty0fd);
+ } else {
+ terminal_ack_acquire(tty0fd);
+ }
close(tty0fd);
return 0;
}
@@ -610,29 +614,29 @@ int seat_vt_activate(struct seat *seat) {
log_debug("VT activation on non VT-bound seat, ignoring");
return -1;
}
-
- log_debug("switching session from VT activation");
seat_update_vt(seat);
+ log_debug("activating VT");
+ vt_ack(seat, false);
if (seat->active_client == NULL) {
seat_activate(seat);
}
return 0;
}
-int seat_prepare_vt_switch(struct seat *seat) {
+int seat_vt_release(struct seat *seat) {
assert(seat);
if (!seat->vt_bound) {
- log_debug("VT switch request on non VT-bound seat, ignoring");
+ log_debug("VT release request on non VT-bound seat, ignoring");
return -1;
}
seat_update_vt(seat);
- log_debug("acking VT switch");
+ log_debug("releasing VT");
if (seat->active_client != NULL) {
seat_disable_client(seat->active_client);
}
- vt_ack(seat);
+ vt_ack(seat, true);
seat->cur_vt = -1;
return 0;
}
diff --git a/seatd/server.c b/seatd/server.c
index 90aa610..acb366e 100644
--- a/seatd/server.c
+++ b/seatd/server.c
@@ -97,7 +97,7 @@ static int server_handle_vt_rel(int signal, void *data) {
return -1;
}
- seat_prepare_vt_switch(seat);
+ seat_vt_release(seat);
return 0;
}