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

2020-08-27 Thread Paul Eggert
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

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

2020-08-27 Thread Zack Weinberg
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;

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

2020-08-27 Thread Paul Eggert
+ 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

[RFC PATCH 2/2] _AS_ENSURE_STANDARD_FDS: use lsof and fstat when possible

2020-08-27 Thread Zack Weinberg
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

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

2020-08-27 Thread Zack Weinberg
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.