Better handling if parent closes REDO_CHEATFDS or MAKEFLAGS fds.

Silently recover if REDO_CHEATFDS file descriptors are closed, because
they aren't completely essential and MAKEFLAGS-related warnings already
get printed if all file descriptors have been closed.

If MAKEFLAGS --jobserver-auth flags are closed, improve the error
message so that a) it's a normal error instead of an exception and b)
we link to documentation about why it happens.  Also write some more
detailed documentation about what's going on here.
This commit is contained in:
Avery Pennarun 2019-01-18 00:06:18 +00:00
commit 3dbdfbc06f
16 changed files with 136 additions and 47 deletions

16
t/204-makeflags/all.do Normal file
View file

@ -0,0 +1,16 @@
# Make sure we can survive if a process closes all file descriptors,
# including any jobserver file descriptors, as long as they also
# unset MAKEFLAGS.
redo-ifchange ../../redo/py
# If we leave MAKEFLAGS set, then it's fair game to complain that the
# advertised file descriptors are gone, because GNU make also complains.
# (Although they only warn while we abort. They can't abort so that
# they don't break backward compat, but we have no such constraint, because
# redo has always failed for that case.)
#
# On the other hand, we shouldn't have to unset REDO_CHEATFDS, both for
# backward compatibility, and because REDO_CHEATFDS is undocumented.
# redo should recover silently from that problem.
unset MAKEFLAGS
../../redo/py ./closefds.py redo noflags

1
t/204-makeflags/clean.do Normal file
View file

@ -0,0 +1 @@
rm -f *~ .*~

View file

@ -0,0 +1,12 @@
import subprocess, sys, os
# subprocess.call(close_fds=True) is unfortunately not a good idea,
# because some versions (Debian's python version?) try to close inordinately
# many file descriptors, like 0..1000000, which takes a very long time.
#
# We happen to know that redo doesn't need such huge fd values, so we'll
# just cheat and use a smaller range.
os.closerange(3, 1024)
rv = subprocess.call(sys.argv[1:])
sys.exit(rv)

View file

@ -0,0 +1 @@
true