Is there a way of emulating the Linux virtual console inside X? I. e. an environment where /dev/tty for all practical purposes (ioctl_console(2)) acts exactly as the Linux console would but that runs as an X client and can be fired up at will and allows screenshots?

I want to avoid having to resort to QEMU if possible.

(Note that a terminal emulator will no do as it does not support the required ioctl()s.)

Background: I’m programming against the virtual console and need a more efficient (and possibly automatable) approach to testing.

  • What exactly do which terminal emulators not support? Nov 23 at 20:59
  • @HaukeLaging: “What exactly do which terminal emulators not support?” — the ioctls I gave. E. g. int main(){char c; assert(ioctl (0, KDGETLED, &c) == 0); }. Nov 23 at 21:18


While you could emulate any ioctl()s you want with cuse, that's not enough to implement a terminal like /dev/tty1 is -- whose interface also includes job control (i.e. correctly forwarding signals like SIGHUP or SIGTTIN to processes), not just some extra ioctl()s.

Notice that you can make a snapshot of real linux "console" has via the /dev/vcsX and /dev/vcsaX (text mode) or /dev/fbX (framebuffer), so reimplementing it sounds pretty pointless -- just like targetting the linux console in particular, which is not even guaranteed to exist even on Linux systems (and in fact it does not exists on 99.9% of Linux systems ;-))

New contributor
user502533 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • I hadn’t heard about CUSE, thanks for the pointer. Very intriguing, but it’d also mean that I have to implement the kernel side of things. Unlikely to happen today. ;) Nov 23 at 22:34
  • “Notice that you can make a snapshot of real linux "console"” — oh yeah, definitely. Still to actually run test code on that console I’d have to deal with getty. Which would be a pain to automate and probably requires privileged access. Booting a VM is probably the simpler approach. Nov 23 at 22:34
  • “And in fact it does not exists on 99.9% of Linux systems” — granted, though it exists on 100 % of systems I care for. ;) Nov 23 at 22:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.