Using multiple consoles

Updated: April 19, 2023

If your system supports multiple consoles or multiple serial ports, you can run the shell on each console and serial port.

Running multiple shell instances

To run the shell on every console and serial port on your system:

  1. Start the console driver with the -n option to ask for more than one console (in this case, we asked for four virtual consoles).
  2. Redirect standard input, output, and error to each of the consoles in turn.
  3. Start the shell on each console.
[+script] .script = {
    # start any other drivers you need here
    devc-con -e -n4 &
    reopen /dev/con1
    [+session] esh &
    reopen /dev/con2
    [+session] esh &
    ...
Note: Run the shell in the background (using the ampersand character “&” at the end of the line). If you don't instruct the shell to run in the background, then the interpretation of the script will suspend until the shell exits.

Starting other programs on consoles

To run other programs on different consoles, you can use the same method you use to start the shell on multiple consoles. For instance, to start multiple serial ports:

  1. Start the appropriate serial driver (e.g., devc-ser8250).
  2. Redirect standard input, output, and error for each port (e.g., /dev/ser1, /dev/ser2).
  3. Run the appropriate executable (in the background) after the redirection (see Redirection below).

The [+session] attribute makes the program the session leader (as per POSIX); not all programs require this attribute.

Redirection

You perform a reopen on any device as many times as you want. You would do this, for example, to start a program on /dev/con1, then start the shell on /dev/con2, and then start another program on /dev/con1 again. For example:

[+script] .script = {
    ...
    reopen /dev/con1
    prog1 &
    reopen /dev/con2
    [+session] esh &
    reopen /dev/con1
    prog2 &
    ...