On 8/27/20 3:20 PM, Zack Weinberg wrote:
On Thu, Aug 27, 2020 at 2:09 PM Paul Eggert wrote:
+ if (exec 3>&0) 2>/dev/null; then :; else exec 0&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
On Thu, Aug 27, 2020 at 2:09 PM Paul Eggert wrote:
>
> > + if (exec 3>&0) 2>/dev/null; then :; else exec 0 > + 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;
+ if (exec 3>&0) 2>/dev/null; then :; else exec 0&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
This follow-up patch adds additional ways of detecting whether fds 0,
1, 2 are closed, using the ‘lsof’ and ‘fstat’ utilities. The former
is not a standard component of any OS, but is very widely installed
and can produce machine-parseable output; the latter ships with many
BSD variants but its
A patch was recently proposed for GNU libc to make *all* processes
start up with file descriptors 0, 1, and 2 guaranteed to be open.
Part of the rationale for this patch was that configure scripts fail
catastrophically if these fds are closed, even if you just want to run
--help or --version, e.g.