Re: RFC PATCH 1/2] AS_INIT: try to ensure fds 0, 1, 2 are open

Paul Eggert <[email protected]>
Newsgroups gmane.comp.sysutils.autoconf.patches
Organization UCLA Computer Science Department
Message-ID <[email protected]>
> +  if (exec 3>&0) 2>/dev/null; then :; else exec 0</dev/null; fi
> +  if (exec 3>&1) 2>/dev/null; then :; else exec 1>/dev/null; fi
> +  if (exec 3>&2)            ; then :; else exec 2>/dev/null; fi

This is all _AS_ENSURE_STANDARD_FDS needs to do; none of the other stuff is 
needed and I suggest omitting it as a maintenance time-sink.

POSIX programs and utilities merely need file descriptors 0, 1, and 2 to be 
open; it doesn't matter whether they're open for read or for write. The point is 
that an ordinary 'open' syscall should never return FDs 0 thru 2; not that 
'read' from 0 or 'write' to 1 or 2 must succeed (there's never any guarantee of 
that).
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.