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.
This commit is contained in:
Kenny Levinsen 2020-09-22 01:00:18 +02:00
parent ba4c422659
commit be45c480ec
5 changed files with 30 additions and 15 deletions

View file

@ -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;
}