NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Getty on USB serial port



On Fri 15 Sep 2017 at 16:29:32 +0200, Michael van Elst wrote:
> On Fri, Sep 15, 2017 at 05:52:10AM -0400, William D. Jones wrote:
> > * I wanted to use the serial port that defaults to the console on my rpi as
> > the ppp connection for various logistical reasons. Can I redirect kernel
> > messages (and init messages) to another tty without recompiling? I don't see
> > a kernel option in `man boot`.
> 
> The kernel messages always go to the "console", which is a low-level
> interface. The kernel only knows two such devices (or three since a few
> days), which are the serial port, the framebuffer/keyboard and the
> second serial port (for RPI3 support).

Look at tty(4), TIOCCONS:

     TIOCCONS int *on
                 If on points to a non-zero integer, redirect kernel console
                 output (kernel printf's) to this terminal.  If on points to a
                 zero integer, redirect kernel console output back to the
                 normal console.  This is usually used on workstations to
                 redirect kernel messages to a particular window.

> Once the kernel is running, the console can be intercepted by a program.
> In standard X11 there is a xconsole doing this, which displays the
> messages in a window.

I suspect that xconsole does this by opening a pty and issuing TIOCCONS
on it.

Screen can also issue TIOCCONS:

       console [on|off]

       Grabs or un-grabs the machines console output to a window.  Note: Only
       the owner of /dev/console can grab the console output.  This command is
       only available if the machine supports the ioctl TIOCCONS.

Apart from that, a simple program to issue the ioctl on stdout is easily
written.

-Olaf.
-- 
___ Olaf 'Rhialto' Seibert  -- Wayland: Those who don't understand X
\X/ rhialto/at/falu.nl      -- are condemned to reinvent it. Poorly.

Attachment: signature.asc
Description: PGP signature



Home | Main Index | Thread Index | Old Index