Re: printk -- unable to print messages

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

 



On 3/8/06, krishna.vamsi@xxxxxxxxx <krishna.vamsi@xxxxxxxxx> wrote:
> bt i  would like to know why it cant print whn we are in XTerm,, wild guess suggests  me of problem related to the tty and pts drivers,,, i'm afraid it may not be  !!!
>
> can  any one clarify this ????
>
printk() puts messages into a ring buffer inside the kernel. It knows
nothing about wether or not you are in text mode or not, nor does it
care. All it does is put the messages into the buffer and then it's up
to tools like klogd/syslogd (read their man pages for details) to move
the messages from that buffer and into your logs (or output them on
your console or whatever you want to happen with them).

What usually happens is that all messages go into your system log
files (unless the system crashed, then they may not have made it that
far) and in addition, important messages (those with a loglevel above
a certain treshold) are also printed on the system console. Now the
"console" is not just any random shell you may have open - it's
/dev/console - the system console role is usually assigned to the very
first tty or sometimes a serial port, so if you want to view the
messages on the screen as they get printed you need to be working on
the system console.
For X there's a program called "xconsole" that can show system console
messages in a graphical window on your X desktop.

If you want to take a peak at what's currently in the kernels message
buffer, the "dmesg" program is provided for that purpose.
So you can run your code, then run dmesg to see whatever messages it
put into the message buffer if you are not on the console or you don't
want to go read the logs.
Note that the kernels message buffer is a ring buffer of a fixed size
(set at compile time), this means that whenever the buffer gets full
the oldest message is overwritten with the newest one, so it doesn't
always hold all messages going back to when the system was booted up -
for that you need to look at your system logs. dmesg just shows you
what is in the buffer right now.

I hope that explanation clarified things a bit for you.

--
Jesper Juhl <jesper.juhl@xxxxxxxxx>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux