apenwarr-redo/t/204-makeflags/closefds.py
Avery Pennarun 3dbdfbc06f 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.
2019-01-18 00:11:48 +00:00

12 lines
430 B
Python

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)