diff options
author | Zack Weinberg <zackw@panix.com> | 2020-08-27 11:02:45 -0400 |
---|---|---|
committer | Zack Weinberg <zackw@panix.com> | 2020-08-27 11:23:54 -0400 |
commit | d2467ed054ea5dee1e59d826f257027aefda9fef (patch) | |
tree | 9b6d855659556f489da1a11b4db15b6294db7364 /.prev-version | |
parent | 821ae462daf8650ec4e5b6d25352b0888f515ba2 (diff) | |
download | autoconf-zack/ensure-standard-fds.tar.gz |
_AS_ENSURE_STANDARD_FDS: use lsof and fstat when possiblezack/ensure-standard-fds
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 output is in a fixed format not designed for
machine parsing. Both of them may fail due to privilege restrictions.
The biggest problem with using these is that we have to run a program
and inspect its output. I tried capturing the output using command
substitution, but that is often implemented using a pipe from the
child process to the parent shell; if fd 0 (for instance) started out
closed in the parent, the pipe is likely to occupy that fd number
right when lsof/fstat is inspecting the parent’s file table, causing a
false report that fd 0 is open. The only alternatives I am aware of
are temporary files or named pipes, both of which involve creating
directory entries somewhere...and we can’t assume we have mktemp(1).
This patch uses a file in the current working directory, but that
breaks all of the tests that assume ‘configure --help’ will not write
to the current working directory (which seems like a reasonable
promise for us to make, tbh).
Better ideas solicited.
* lib/m4sugar/m4sh.m4 (_AS_ENSURE_STANDARD_FDS): If /proc/<pid>/fdinfo
is not available, try to use lsof or fstat.
Diffstat (limited to '.prev-version')
0 files changed, 0 insertions, 0 deletions