where does stdout link to?


 
Thread Tools Search this Thread
Special Forums Hardware Filesystems, Disks and Memory where does stdout link to?
# 1  
Old 06-16-2003
Question where does stdout link to?

As I read the source code of unix I wonder where u_ofile[0](it should be stdout) link to ?

Does it link to a file structure like ordinary files? Smilie
# 2  
Old 06-17-2003
That's up to the program that spawns the process. As a default, most shells will default stdout to /dev/tty. But if, for example, you do:
someprog > /dev/null
then stdout will be pointing to /dev/null.
# 3  
Old 06-17-2003
Quote:
Originally posted by Perderabo
That's up to the program that spawns the process. As a default, most shells will default stdout to /dev/tty. But if, for example, you do:
someprog > /dev/null
then stdout will be pointing to /dev/null.

you mean u-ofile[0] connects to struct tty?

or it still connects first to struct file then to inode?

if it is an ordinary file it will connect like this:

process pa
u-ofile
-------------
| stdin |
-------------
| stdout |
-------------
| stderr | file inode
------------- -------------- ------------
| |------------------------> | |--------->| |
------------- -------------- ------------



Is it like:

process pa
u-ofile
-------------
| stdin | tty
------------- ----------------
| stdout |-----------------------> | |
------------- ---------------
| stderr |
-------------

?

right??Smilie
# 4  
Old 06-17-2003
Quote:
Originally posted by Perderabo
That's up to the program that spawns the process. As a default, most shells will default stdout to /dev/tty. But if, for example, you do:
someprog > /dev/null
then stdout will be pointing to /dev/null.
sorry i don't know how it become like this .....hope i will be understood!

you mean u-ofile[0] connects to struct tty?

or it still connects first to struct file then to inode?

if it is an ordinary file it will connect like this:

process pa

u-ofile
stdin
stdout
stderr
fd1--------->file structure---->inode

Is it like:

process pa
u-ofile
| stdin |
| stdout |--------->tty
| stderr |

?

right??SmilieSmilie Smilie

Last edited by jiangyanna; 06-17-2003 at 09:05 AM..
# 5  
Old 06-17-2003
The internal detail vary based on the kernel and the details that you are quoting are alien to me. The fd table points to a system file table entry. The first one is called stdout. With the kernels I know, the file table will then point to a vnode.

/dev/tty and /dev/null are not called ordinary files. They are called special files because they actually connect to a driver.

But stdout is opened just like every other file...well it could be a socket. But the kernel does not treat fd 0 any differently than, say, fd 5.
# 6  
Old 06-18-2003
MySQL thanks a lot

O! so the fd0 is also first points to a file structure right ?

thanks,you really help me a lot with my final exam.

Smilie
# 7  
Old 06-18-2003
BTW

Can you introduce me some reference about this topic?

thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

/var/adm/messages (insterface turned off/restored) and link up & link down message.

Hi All I am facing an issue with our new solaris machine. in /var/adm/messages Apr 22 16:43:05 Prod-App1 in.routed: interface net0 to 172.16.101.1 turned off Apr 22 16:43:33 Prod-App1 mac: NOTICE: nxge0 link up, 1000 Mbps, full duplex Apr 22 16:43:34 Prod-App1 mac: NOTICE: nxge0 link... (2 Replies)
Discussion started by: javeedkaleem
2 Replies

2. Solaris

/var/adm/messages (interface turned off/restored) and link up & link down message.

Hi All I am facing an issue with our new solaris machine. in /var/adm/messages root@Prod-App1:/var/tmp# root@Prod-App1:/var/tmp# root@Prod-App1:/var/tmp# cat /var/adm//messages Apr 20 03:10:01 Prod-App1 syslogd: line 25: WARNING: loghost could not be resolved Apr 20 08:24:18 Prod-App1... (0 Replies)
Discussion started by: javeedkaleem
0 Replies

3. UNIX for Dummies Questions & Answers

[Solved] Symbolic link not allowed or link target not accessible

Hi everybody, I read about treads realted to this issue but they did not resovle issue given below. Please help me resolve issue given below I have html file under /srv/www/htdocs/actual_folder ls actual_folder/ test.html and following link works... (0 Replies)
Discussion started by: newbielgn
0 Replies

4. Programming

g++ fails to link to static library when compilation and link in single command

Hello All, I've encountered a strange behaviour from g++ that doesn't make sense to me. Maybe you can shed some light on it: I have a bunch of source files and want to compile them and link them with a static library liba.a located in /usr/local/lib64 into an executable Approach 1 works... (0 Replies)
Discussion started by: magelord
0 Replies

5. UNIX for Dummies Questions & Answers

Difference between hard link and soft link

Hi Experts, Please help me out to find out difference between a hard link and a soft link. I am new in unix plz help me with some example commands ( for creating such links). Regards S.Kamakshi :) (2 Replies)
Discussion started by: kamakshi s
2 Replies

6. UNIX for Dummies Questions & Answers

Hard Link vs SOft Link????

Hi PLease let me know the usage of Hard Link vs Soft Link i.e what is the basic difference and what happens when one file is changed or deleted in both the cases??? thanks (3 Replies)
Discussion started by: skyineyes
3 Replies

7. UNIX for Dummies Questions & Answers

need some info about symbolic link and hard link

hello folks how y'all doin well i have some questions about symbolic link and hard link hope some one answer me i open terminal and join as root and i wrote ln -s blah blah then i wrote ls i see red file called blah blah but didn't understand what is this can some one explain and... (2 Replies)
Discussion started by: detective linux
2 Replies

8. UNIX for Dummies Questions & Answers

Difference between hard link and soft link in unix

Hi All, Can any one please explain me what is the difference between hard link and soft link in UNIX. Thanks in advance Raja Chokalingam. (2 Replies)
Discussion started by: RAJACHOKALINGAM
2 Replies

9. UNIX for Advanced & Expert Users

Differences between hard link and soft link

Hi all! I'd like to know the differences between hard links and soft links. I've already read the ln manpage, but i'm not quite sure of what i understood. Does a hard link sort of copy the file to a new name, give it the same inode number and same rights? What exactly should I do to do this:... (3 Replies)
Discussion started by: penguin-friend
3 Replies
Login or Register to Ask a Question