Penguin

Differences between current version and predecessor to the previous major change of stdout(3).

Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History

Newer page: version 2 Last edited on Thursday, February 20, 2003 11:19:36 pm by PerryLorier
Older page: version 1 Last edited on Monday, June 3, 2002 11:57:34 pm by perry Revert
@@ -1,95 +1,33 @@
-----  
-__NAME__  
-  
-  
 stdin, stdout, stderr - standard I/O streams 
-__ SYNOPSIS__  
-  
-  
-#include  
-extern FILE stdin;  
-extern FILE stdout;  
-extern FILE stderr;  
-__ DESCRIPTION__  
-  
-  
-Under normal circumstances every Unix program has three  
- streams opened for it when it starts up, one for input, one  
- for output, and one for printing diagnostic or error mes-  
- sages. These are typically attached to the user's terminal  
- (see tty(4)) but might instead refer to files or  
- other devices, depending on what the parent process chose to  
- set up. (See also the ``Redirection'' section of  
- sh(1) .)  
-  
+!!! SYNOPSIS  
+ #include <stdio.h>  
+ extern FILE stdin;  
+ extern FILE stdout;  
+ extern FILE stderr;  
+!!! DESCRIPTION  
+Under normal circumstances every Unix program has three streams opened for it when it starts up, one for input, one for output, and one for printing diagnostic or error mes- sages. These are typically attached to the user's terminal (see tty(4)) but might instead refer to files or other devices, depending on what the parent process chose to set up. (See also the ``Redirection'' section of sh(1) .) 
  
 The input stream is referred to as ``standard input''; the output stream is referred to as ``standard output''; and the error stream is referred to as ``standard error''. These terms are abbreviated to form the symbols used to refer to these files, namely stdin, stdout, and stderr. 
  
+Each of these symbols is a stdio(3) macro of type pointer to FILE, and can be used with functions like fprintf(3) or fread(3).  
  
-Each of these symbols is a stdio(3) macro of type  
-pointer to FILE , and can be used with functions like  
-fprintf (3 ) or fread (3 ). 
+Since FILEs are a buffering wrapper around Unix file descriptors , the same underlying files may also be accessed using the raw Unix file interface, that is, the functions like read (2 ) and lseek (2 ). The integer file descriptors associated with the streams stdin, stdout, and stderr are , 1, and 2, respectively. The preprocessor  
+symbols STDIN_FILENO, STDOUT_FILENO, and STDERR_FILENO are defined with these values in <unistd.h>  
  
  
-Since FILEs are a buffering wrapper around Unix file  
- descriptors, the same underlying files may also be accessed  
-using the raw Unix file interface , that is, the functions  
-like read(2 ) and lseek(2). The integer  
- file descriptors associated with the streams stdin , stdout ,  
-and stderr are , 1 , and 2, respectively . The preprocessor  
-symbols STDIN_FILENO, STDOUT_FILENO, and STDERR_FILENO are  
-defined with these values in  
+Note that mixing use of FILEs and raw file descriptors can produce unexpected results and should generally be avoided. (For the masochistic among you: POSIX.1 , section 8.2.3, describes in detail how this interaction is supposed to work. ) A general rule is that file descriptors are handled in the kernel , while stdio is just a library. This means for example , that after an exec , the child inherits all open file descriptors , but all old streams have become inaccessible
  
-  
-Note that mixing use of FILEs and raw file descriptors can  
-produce unexpected results and should generally be avoided.  
-(For the masochistic among you: POSIX.1, section 8.2.3,  
-describes in detail how this interaction is supposed to  
-work.) A general rule is that file descriptors are handled  
-in the kernel, while stdio is just a library. This means for  
-example, that after an exec, the child inherits all open  
-file descriptors, but all old streams have become inaccessi-  
-ble.  
-  
-  
- Since the symbols stdin, stdout, and stderr are specified to  
- be macros, assigning to them is non-portable. The standard  
- streams can be made to refer to different files with help of  
- the library function freopen(3), specially  
- introduced to make it possible to reassign stdin, stdout,  
- and stderr. The standard streams are closed by a call to  
- exit(3) and by nor- mal program 
+Since the symbols stdin, stdout, and stderr are specified to be macros, assigning to them is non-portable. The standard streams can be made to refer to different files with help of the library function freopen(3), specially introduced to make it possible to reassign stdin, stdout, and stderr. The standard streams are closed by a call to exit(3) and by normal program 
 termination. 
-__ SEE ALSO__  
-  
-  
-sh(1), csh(1), open(2),  
- fopen(3), stdio(3)  
-__CONSIDERATIONS__  
-  
-  
-The stream stderr is unbuffered. The stream stdout is  
-line-buffered when it points to a terminal. Partial lines  
-will not appear until fflush (3) or exit(3)  
-is called , or a newline is printed. This can produce  
-unexpected results, especially with debugging output. The  
-buffering mode of the standard streams (or any other stream)  
-can be changed using the setbuf (3) or  
-setvbuf(3) call. Note that in case stdin is  
-associated with a terminal, there may also be input  
-buffering in the terminal driver, entirely unrelated to  
-stdio buffering. (Indeed, normally terminal input is line  
-buffered in the kernel.) This kernel input handling can be  
-modified using calls like tcsetattr(3); see also  
-stty(1), and termios(3).  
-__CONFORMING TO__  
-  
+!!! SEE ALSO  
+sh(1), csh(1), open(2), fopen(3), stdio(3), stdout(3), stderr (3) 
  
-The stdin, stdout, and stderr macros conform to  
-ANSI X3 .159 -1989 (`` ANSI C  
-'' ), and this standard also stipulates that these three  
-streams shall be open at program startup
+!!!CONSIDERATIONS  
+ The stream stderr is unbuffered . The stream stdout is line -buffered when it points to a terminal. Partial lines will not appear until fflush (3 ) or exit(3)  
+is called , or a newline is printed. This can produce unexpected results, especially with debugging output. The buffering mode of the standard streams (or any other stream) can be changed using the setbuf(3) or setvbuf(3) call. Note that in case stdin is associated with a terminal, there may also be input  
+buffering in the terminal driver, entirely unrelated to stdio buffering. (Indeed, normally terminal input is line buffered in the kernel.) This kernel input handling can be modified using calls like tcsetattr(3); see also stty(1), and termios(3)
  
+!!!CONFORMING TO  
+The stdin, stdout, and stderr macros conform to ANSI X3.159-1989 (`` ANSI C ''), and this standard also stipulates that these three streams shall be open at program startup.  
  
 Linux 2.0 March 24, 1998 1 
-----  
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.