Re: Linux console interface



"MQ" <michaelquinlivan@xxxxxxxxx> wrote:

Is any one able to answer my questions?

Russell offered you a very good answer.

1. How is STDIN/STDOUT/STDERR opened? Is this done by getty, and then
all applications descended from getty just inherit this?

The best thing about Linux is that you can go look it up. You have the
source code.

Remember that stdin/stdout/stderr do not necessarily connect to a console.
Consider:
ls -l > savethis

In this case, the shell is going to have to open "savethis" and pass the
handle as "stdout". Without any redirection, the shell must duplicate the
stdout handle it received. I would guess that getty is probably the one
that starts it all.

2. I know that keyboard input is obtained by reading STDIN and screen
output is acheived by writing to STDOUT. How do you send the console
configuration options. You can do this via the termios functions of
the C library, but does the C library acheive this using ioctls?

Yes. Many programs just make the ioctl calls directly and bypass termios.

I think it does, but I thought console ioctls may change between kernel
versions. Should I just support the latest kernel version and risk old
applications breaking if they do ioctls directly (that is not through
termios)?

Theoretically, this is true. However, the terminal control ioctls have
been stable for many decades. They were present in the early versions of
Unix, and no kernel developer who hoped to retain his gonads would propose
changing them now.

3. What C module is the top-level terminal driver in the Linux kernel.
That is, the one that is attached to major char device 4? Also, what
is the association between the terminal driver and /dev/console. They
seem to be two separate devices (/dev/console is on major number 5)

Major number 4 handles the virtual terminals for the system's keyboard and
monitor, as well as terminals coming in via serial ports. Major number 5
is used for the "current" virtual terminal and for outgoing serial
connections. A book, or the source code, would help you clear this up.
--
Tim Roberts, timr@xxxxxxxxx
Providenza & Boekelheide, Inc.
.



Relevant Pages

  • Re: getty
    ... VN> terminals or serial lines, ... Traditionally, accepting ... VN> You need getty to accept logins from "console directly". ...
    (comp.unix.programmer)
  • Re: definition of terminal, et cetera
    ... this usually means a keyboard ... > A console is a keyboard and screen directly connected to a CPU. ... > terminals, terminal emulators, that is, software running on a computer ... which calls getty which calls login which calls the shell ...
    (comp.unix.programmer)
  • Re: getty + Specialix + rs506a
    ... something to do with replacing the after rs506a getty with the previous ... Paulo Couceiro ... > | terminals, once login and logout done, they have hanged. ...
    (comp.unix.sco.misc)