flags = os.environ['MAKEFLAGS']
# Look for "--jobserver=R,W"
+ # Note that GNU Make has used --jobserver-fds and --jobserver-auth
+ # so this handles all of them.
opts = [x for x in flags.split(" ") if x.startswith("--jobserver")]
# Parse out R,W file descriptor numbers and set them nonblocking.
# If the jobserver was (impossibly) full or communication failed, use default.
if len(jobs) < 1:
print(default)
+ sys.exit(0)
# Report available slots (with a bump for our caller's reserveration).
print(len(jobs) + 1)