Hi Sam, Thanks for a delightfully illuminating analysis. I hope you enjoyed the sleuthing, even if it did cost you a month !
> The TLDR of the above: make reads the job server's file descriptors > from the MAKEFLAGS environment variable, then checks here if they > actually exist. If they don't exist, make will create the job server > pipe. Important: by default they will be file descriptors 3 and 4. > This becomes a key player in this mystery, a little bit later. > > When make spawns a child job (other than a recursive make) the job > server file descriptors get closed (marked O_CLOEXEC before the actual > execve), but MAKEFLAGS remains in the environment. Sounds to me like that's a bug: when the descriptors are closed, the part of MAKEFLAGS that claims they're make's jobserver file descriptors should be removed, since that's when the claim stops being true. Eddy.