On Mon, Jun 28, 2021 at 2:53 PM Vincent Lefevre via austin-group-l at The
Open Group <[email protected]> wrote:

> On 2021-06-28 21:28:37 +0700, Robert Elz wrote:
> >     Date:        Mon, 28 Jun 2021 15:48:33 +0200
> >     From:        Vincent Lefevre <[email protected]>
> >     Message-ID:  <[email protected]>
> >
> >   | So, if writing to a closed fd yields unspecified behaviour, what
> >   | does "refers to no open file" mean?
> >
> > No, you misunderstood.   It isn't writing to the closed fd, that's
> perfectly
> > defined (as you quoted) what generates unspecified behaviour is invoking
> > any of the standard utilities (non-standard ones are always unspecified
> of
> > course) with any of stdin stdout or stderr not properly opened (stdin for
> > reads, at least, stdout and stderr for writes).
>
> Where is this written (at least for the particular case of builtins)?
>

For real exec() calls, XSH, description of the exec family:
    If file descriptor 0, 1, or 2 would otherwise be closed after a
successful call to one of the exec
    family of functions, implementations may open an unspecified file for
the file descriptor in the
    new process image. If a standard utility or a conforming application is
executed with file
    descriptor 0 not open for reading or with file descriptor 1 or 2 not
open for writing, the
    environment in which the utility or application is executed shall be
deemed non-conforming,
    and consequently the utility or application might not behave as
described in this standard.

For the shell, XCU 2.9.1 "simple commands", last paragraph:
    If the utility would be executed with file descriptor 0, 1, or 2
closed, implementations may
    execute the utility with the file descriptor open to an unspecified
file. If a standard utility or a
    conforming application is executed with file descriptor 0 not open for
reading or with file
    descriptor 1 or 2 not open for writing, the environment in which the
utility or application is
    executed shall be deemed non-conforming, and consequently the utility
or application might not
    behave as described in this standard.


Philip Guenther

Reply via email to