Question re ncurses and the various ttys

Raaf freebsd at
Thu Oct 12 14:36:23 PDT 2006

> Hi all
> I've been digging around in the various man pages and havent yet found
> the 
> incantations I require.
> Goal: to create a curses driven status screen that can run without user
> intervention.
> I want to know if it is possible to _programatically_ switch to an
> unused 
> virtual tty,

Yes it is certainly possible, i have done this recently myself and like
you i couldn't find how to do it in any man page. Fortunately i could find
the answer in the xorg-server source code.

You just open one of the virtual terminals and issue the VT_ACTIVATE

fd = open("/dev/ttyv9",O_RDONLY);

> and then use this as the display page.
> ( By unused I mean marked 'off' in /etc/ttys )

Well, the above code only switches the active vt...

If you want your program output to go to a certain vt you probably have
to open the specific vt and replace the stdin and stdout file descriptors
of your program with the one of the one of the vt you just opened.

But there are probably some caveats to this method, so best is to take a
look at the getty source code and maybe add your program to /etc/ttys.

More information about the freebsd-questions mailing list