C Switch active console programmatically

dear all,

I built an app with ncurses display UI..
I have problem if I used virtual console-1 since the system log keeps displaying into the console-1. So, I need to use another console (ex: console-2) for my display UI..
Therefore I need to switch into console-2 automatically after OS booting finished..
Is it possible to switch the active console via C code rather than pressing keyboard key Alt+Ctrl+n ?

Thank you.
 
that's not going to be easy, because of termcap way it is built.

You may eventually look at boot script that would allow more control.

tcc / term / ncurses is my favorite since years yeras.
 
dear all,

I built an app with ncurses display UI..
I have problem if I used virtual console-1 since the system log keeps displaying into the console-1. So, I need to use another console (ex: console-2) for my display UI..
Therefore I need to switch into console-2 automatically after OS booting finished..
Is it possible to switch the active console via C code rather than pressing keyboard key Alt+Ctrl+n ?

Thank you.
You can do that with vidcontrol(1): vidcontrol -s 2 < /dev/ttyv0

You can also do that from C with something like
Code:
#include <sys/consio.h>
#include <fcntl.h>
// ...
int fd = open("/dev/ttyv0", O_RDONLY);
ioctl(fd, VT_ACTIVATE, 2);
 
Back
Top