stdout to console

Sri Ram Vemulpali sri.ram.gmu06 at gmail.com
Fri Apr 27 01:46:08 EDT 2012


Dude,

It is more of implementation dependent. Where you want your output to display.
pty is a method of sending data between two end points of
communications but acts with concept of master and slave. It is
written on tty driver.

In case of ssh it is implementation dependent.

I will leave it to you to understand the concept of vfs. Initially it
is confusing, but there is lot of material online. You url is a good
start.

All the best.

Sri.


On Wed, Apr 25, 2012 at 11:56 PM, Arun KS <getarunks at gmail.com> wrote:
> Thanks Sri Ram and Jonathan,
>
> On Wed, Apr 25, 2012 at 11:39 PM, Sri Ram Vemulpali
> <sri.ram.gmu06 at gmail.com> wrote:
>> Ok I see your problem.
>>
>> vfs maintains file descriptor table for every process in the system.
>> At every index it stores information of descriptor type and device it
>> points to. The indexes 0,1,2 have special meaning in the context of
>> process. 0 indicates std input, 1 indicates std output and 2 indicates
>> std err.
>> So whenever you use open(), socket(), or any other system call which
>> returns descriptor (expect fopen .. libc functions) is returning the
>> index in to this table where the info about device or operation is
>> stored. So, whenever you use that descriptor number with other sys
>> calls it will map in to index and extracts the information.
>>
>> normal calls like printf, cout uses "stdin, stdout, stderr" for printing out.
>>
>>> We all know that when an application writes to stdout, data ends up in
>>> the console.
>> Because for that process index 1 maps to /dev/stdout
>>
>>> 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).
>> same as above
>>
>>> If I m on any server using ssh and all apps prints comes on my putty
>>> (eg through /dev/pts/176).
>> its ssh implementation. It uses pty as stdout for printing.
> Okey
>> In such case initializing stdout = fdopen on open("/dev/stdout", "")
>> descriptor will do your job.
>> or use dup to set index 1 to given fd in that process
>
> Hmm... Will sshd open /dev/stdout?
>
> I think it uses /dev/ptmx and /dev/pts/* device files.
>
> Plz have a look here,
> http://linux.die.net/man/4/pts
>
> Arun
>
>>
>>
>> --Sri.
>>
>> On Mon, Apr 23, 2012 at 6:15 AM, Arun KS <getarunks at gmail.com> 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
>>>
>>> _______________________________________________
>>> Kernelnewbies mailing list
>>> Kernelnewbies at kernelnewbies.org
>>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>
>>
>>
>> --
>> Regards,
>> Sri.



-- 
Regards,
Sri.



More information about the Kernelnewbies mailing list