LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   printf, console and terminal (https://www.linuxquestions.org/questions/linux-general-1/printf-console-and-terminal-929328/)

agentsmith.android1 02-14-2012 01:30 PM

printf, console and terminal
 
Hi,

I m porting to linux to a custom architecture. I have added a system console to get the printk from kernel. However, I am not able to get user space prints working.

I have few questions on this area.

1. How console is related to tty? Do I need to write a new tty driver for my custom architecture.
2. I know printf get directed to stdin/stdout. But what is the relation between tty and these files. How would I know the printf data will call write method of my tty device.
3. In general can someone explain relation between printf->stdin/out->tty->console to me.

eeekster 02-14-2012 02:11 PM

Have you tried writing to /dev/console?

agentsmith.android1 02-14-2012 02:18 PM

I did not write to /dev/console explicitly. I want printf to work as it is. I found stdout/stdin are directed to /dev/pty. Who does this redirection?

eeekster 02-14-2012 02:34 PM

Quote:

Originally Posted by agentsmith.android1 (Post 4602357)
I want printf to work as it is. I found stdout/stdin are directed to /dev/pty. Who does this redirection?

That's setup with the session is created by logging in or starting an xterm, etc.

agentsmith.android1 02-14-2012 03:41 PM

Is there a way to find out which tty will be linked to printf by default? I want to check it before compiling the kernel.

eeekster 02-14-2012 05:21 PM

The definition of /dev/tty is the current terminal a process is running in.

Code:

  5 char    Alternate TTY devices
          0 = /dev/tty      Current TTY device
          1 = /dev/console  System console
          2 = /dev/ptmx    PTY master multiplex
          3 = /dev/ttyprintk    User messages via printk TTY device
        64 = /dev/cua0    Callout device for ttyS0
            ...
        255 = /dev/cua191  Callout device for ttyS191

        (5,1) is /dev/console starting with Linux 2.1.71.  See
        the section on terminal devices for more information
        on /dev/console.



All times are GMT -5. The time now is 01:20 AM.