> You know, I can make a reasonable argument that at program startup it
is
> required for stdin/stdout/stderr to act as if they have just been
opened:
> [#7] At program startup, three text streams are predefined
> and need not be opened explicitly
> implies that they have been opened as if by stdin. So the file open on
> stdin must be at the start and the ones on stdout/stderr must either
be at
> the start or opened in an append mode.
Caution here: this statement should be tested against all the ways a
file can be opened in the shell, and if it precludes any of them, then
it's probably wrong. In particular, depending on how you interpret
things, the following shell lines might be a problem for a version of
cat and an implementation that are both strictly conforming to the
above.
(cat a; cat b) >foo # by some measures, the 2'd cat's access to foo
(stdout) won't be "as if [it] had just been opened".
(head; cat) < bar # there are OTHER synchronization problems with this,
but clearly the cat won't/shouldn't see the beginning of bar (stdin).
cat <&6 # where fd 6 was already open in the shell.
etc.
Donn
|