stdout to console
Jonathan Neuschäfer
j.neuschaefer at gmx.net
Mon Apr 23 08:09:06 EDT 2012
On Mon, Apr 23, 2012 at 03:45:00PM +0530, Arun KS wrote:
> Hello Guys,
>
> We all know that when an application writes to stdout, data ends up in
> the console.
>
> Okey so if I m on my development board and if I run an app, all the
> prints comes to the console (eg /dev/ttyS0).
> If I m on any server using ssh and all apps prints comes on my putty
> (eg through /dev/pts/176).
>
> Where is the code which maps fd 1 to the console in kernel?
> If you guys have any pointers, please share.
>
> While opening a device (for eg /dev/something), the vfs calls that
> drivers, whose major and minor number matches.
> But in case of stdout, how vfs resolves the write to the fd 1 and send
> it to the corresponding console driver?
>
> Thanks,
> Arun
It's in init/main.c, around line 823.
"strace" is a useful tool for trying to figure out what exactly a user
space process does.
The man pages of various system calls (open, fork, exec, dup, etc.) may
also provide valuable information.
Thanks,
Jonathan Neuschäfer
More information about the Kernelnewbies
mailing list