[Previous]
[Contents]
[Next]

console_active()

make a specific console the active one

Synopsis:

#include <sys/console.h>
int console_active( struct _console_ctrl *cc,
                    int console );

Description:

The console_active() function makes the indicated console the active one. This has the effect of making that console visible on the monitor's screen, and causing subsequent keyboard input to be directed to that console.

The argument cc is a pointer to a control structure that was returned by a previous call to console_open(). The console argument has a value of 1 to represent the device named /dev/con1, a value of 2 for /dev/con2, and so on. A value of 0 for console indicates the default console (that is, the one used by console_open()). A value of -1 for console indicates the currently visible console.

The console_active() function returns the number of the console that was visible prior to this call, so the following call returns the currently visible console:

current = console_active(cc, -1);

Note: Keep in mind that users can also change the active console with a keyboard sequence, so there's no guarantee that the console will still be visible by the time the next one of the console functions is called.

Returns:

The number of the console that was active prior to this call. If an error occurs, -1 is returned and errno is set.

Errors:

EACCES
You don't have write permission for the console you are switching to.
EINVAL
The control structure is in the wrong format.
ENXIO
The console value is invalid.

Examples:

#include <sys/console.h>
#include <fcntl.h>
#include <unistd.h>

int main( void )
  {
    struct _console_ctrl *cc;
    int fd, old;

    /*
     * Open up a channel to the console driver
     */
    fd = open( "/dev/con1", O_RDWR );
    cc = console_open( fd, O_RDWR );
    close( fd );

    /*
     * Switch to the second console ( /dev/con2 )
     */
    old = console_active( cc, 2 );

    /*
     * Switch back to original console
     */
    console_active( cc, old );

    /*
     * Close the channel
     */
    console_close( cc );
    return (EXIT_SUCCESS);
  }

Classification:

QNX

Safety:
Interrupt handler No
Signal handler Yes, but modifies errno
Thread Yes

See also:

console_arm(), console_close(), console_ctrl(), console_font(), console_info(), console_open(), console_protocol(), console_read(), console_size(), console_state(), console_write(), errno


[Previous]
[Contents]
[Next]