aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/terminal.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/common/terminal.c b/common/terminal.c
index aa9797e..e397357 100644
--- a/common/terminal.c
+++ b/common/terminal.c
@@ -138,6 +138,31 @@ int terminal_current_vt(int fd) {
log_errorf("could not retrieve VT state: %s", strerror(errno));
return -1;
}
+
+ // The FreeBSD VT_GETACTIVE is implemented in the kernel as follows:
+ //
+ // static int
+ // vtterm_ioctl(struct terminal *tm, u_long cmd, caddr_t data,
+ // struct thread *td)
+ // {
+ // struct vt_window *vw = tm->tm_softc;
+ // struct vt_device *vd = vw->vw_device;
+ // ...
+ // switch (cmd) {
+ // ...
+ // case VT_GETACTIVE:
+ // *(int *)data = vd->vd_curwindow->vw_number + 1;
+ // return (0);
+ // ...
+ // }
+ // ...
+ // }
+ //
+ // The side-effect here being that the returned VT number is one
+ // greater than the internal VT number, which is what is used for e.g.
+ // numbering the associated VT. To simplify things, we subtract one
+ // from the returned VT number before returning it.
+
if (vt < 1) {
log_errorf("invalid vt: %d", vt);
return -1;