terminal: Explain FreeBSD current_vt behavior
This commit is contained in:
parent
dbdce8a54b
commit
27c1914625
1 changed files with 25 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue