Introduction to Unix

../_images/ksus4.jpg ../_images/UNIX_blocks4.jpeg

2.4. Standard Files and File Descriptors

Linux for Programmers and Users, Section 3.5

See also

File Redirection

When each program begins, three file descriptors are open and ready for use.

stdin

The primary input channel for the program. Default source is the user’s keyboard, but it can easily be switched to be from another process via a pipe ( | ) or a file via a file redirection ( < ).

stdout

The primary output channel for program’s data output. Default destination is the user’s screen, but it can easily be switched to another process via a pipe ( | ) or a file via a file redirection ( > ).

stderr

Output channel for error messages. Default destination is the user’s screen, but it can be switched to another process via a pipe ( | ) or a file via a file redirection ( > ). The details of how to do that will be covered later. See File Redirection.

../_images/file_descriptors.png

Logical view of file descriptors