LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-14-2012, 01:30 PM   #1
agentsmith.android1
LQ Newbie
 
Registered: Feb 2012
Posts: 3

Rep: Reputation: Disabled
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.
 
Old 02-14-2012, 02:11 PM   #2
eeekster
Member
 
Registered: Sep 2011
Posts: 163

Rep: Reputation: Disabled
Have you tried writing to /dev/console?
 
Old 02-14-2012, 02:18 PM   #3
agentsmith.android1
LQ Newbie
 
Registered: Feb 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
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?
 
Old 02-14-2012, 02:34 PM   #4
eeekster
Member
 
Registered: Sep 2011
Posts: 163

Rep: Reputation: Disabled
Quote:
Originally Posted by agentsmith.android1 View Post
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.
 
Old 02-14-2012, 03:41 PM   #5
agentsmith.android1
LQ Newbie
 
Registered: Feb 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
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.
 
Old 02-14-2012, 05:21 PM   #6
eeekster
Member
 
Registered: Sep 2011
Posts: 163

Rep: Reputation: Disabled
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to print a message from kernel module to terminal console or tty console yogesh_bansal Linux - Newbie 2 02-27-2009 09:10 AM
Hiding printf( C programming) outputs from console mendiratta General 3 11-20-2008 03:17 AM
printf in bold in KDE Terminal? DaneelGiskard Programming 2 07-22-2007 11:20 AM
process' and printf's in console jnusa Programming 7 01-12-2005 02:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration