At program startup, three streams are predefined and need not be opened explicitly:
standard input, for reading conventional input
standard output, for writing conventional output
standard error, for writing diagnostic output
When opened, the standard error stream is not fully buffered; the standard input and standard output streams are fully buffered if and only if the stream can be determined not to refer to an interactive device. Otherwise, the streams are line buffered.
Depending on which functionality is selected (see section “Selecting the file system and thesystem environment” ), standard I/O streams may be associated with POSIX or BS2000 files.
The following association is created when accessing the DMS:
| SYSDTA SYSOUT |
In this case, behavior is compatible with the earlier versions of the C runtime system (see also section “BS2000 system files”).
Functions that only use POSIX functionality cannot be applied on stdin
, stdout
or stderr
in this case.
When the POSIX file system is accessed, the standard I/O streams are associated with /dev/tty
(see also section “Associating the I/O streams”)
In batch mode, the association is always with SYSFILE, since no terminal is present.In child processes, I/O streams that are associated with SYSFILE can no longer be accessed, even if the association was made via POSIX.
If the association of standard I/O streams is controlled by selecting POSIX functionality with environment variables, the association can be affected by changing the variables with putenv()
: when a program is initiated with one of the exec
functions, the environment variables are reevaluated at C runtime initialization, and the corresponding associations are made for the program started with the exec
function.