I guess I found a bug in the kernel. (My first!).
The consoles reported back in vstat->v_state on the VT_GETSTATE request
are shifted by one, and tty0 is reported twice. (Please don't tell me
POSIX requires this <G>).
Here's the patch: (against 2.0.30)
--- vt.c.orig Wed Aug 20 20:27:19 1997
+++ vt.c Wed Aug 20 20:27:49 1997
@@ -750,5 +750,5 @@
put_user(fg_console + 1, &vtstat->v_active);
state = 1; /* /dev/tty0 is always open */
- for (i = 0, mask = 2; i < MAX_NR_CONSOLES && mask; ++i, mask <<= 1)
+ for (i = 1, mask = 2; i < MAX_NR_CONSOLES && mask; ++i, mask <<= 1)
if (VT_IS_IN_USE(i))
state |= mask;
Han Holl