Notice sooner when make has "helpfully" closed its job control file descriptors.

This commit is contained in:
Avery Pennarun 2010-11-13 05:05:48 -08:00
commit 3803da525c
2 changed files with 10 additions and 2 deletions

View file

@ -1,7 +1,7 @@
all: all:
%: FORCE %: FORCE
./redo $@ +./redo $@
.PHONY: FORCE .PHONY: FORCE

View file

@ -65,6 +65,14 @@ def setup(maxjobs):
b = _atoi(b) b = _atoi(b)
if a <= 0 or b <= 0: if a <= 0 or b <= 0:
raise ValueError('invalid --jobserver-fds: %r' % arg) raise ValueError('invalid --jobserver-fds: %r' % arg)
try:
fcntl.fcntl(a, fcntl.F_GETFL)
fcntl.fcntl(b, fcntl.F_GETFL)
except IOError, e:
if e.errno == errno.EBADF:
raise ValueError('broken --jobserver-fds from make; prefix your Makefile rule with a "+"')
else:
raise
_fds = (a,b) _fds = (a,b)
if maxjobs and not _fds: if maxjobs and not _fds:
# need to start a new server # need to start a new server
@ -81,7 +89,7 @@ def wait(want_token):
if _fds and want_token: if _fds and want_token:
rfds.append(_fds[0]) rfds.append(_fds[0])
r,w,x = select.select(rfds, [], []) r,w,x = select.select(rfds, [], [])
#print 'readable: %r' % r _debug('_fds=%r; wfds=%r; readable: %r\n' % (_fds, _waitfds, r))
for fd in r: for fd in r:
if _fds and fd == _fds[0]: if _fds and fd == _fds[0]:
pass pass