@@ -12,12 +12,6 @@ default="1"
12
12
if len (sys .argv ) > 1 :
13
13
default = sys .argv [1 ]
14
14
15
- # Set non-blocking for a given file descriptor.
16
- def nonblock (fd ):
17
- flags = fcntl .fcntl (fd , fcntl .F_GETFL )
18
- fcntl .fcntl (fd , fcntl .F_SETFL , flags | os .O_NONBLOCK )
19
- return fd
20
-
21
15
# Extract and prepare jobserver file descriptors from envirnoment.
22
16
try :
23
17
# Fetch the make environment options.
31
25
# Parse out R,W file descriptor numbers and set them nonblocking.
32
26
fds = opts [0 ].split ("=" , 1 )[1 ]
33
27
reader , writer = [int (x ) for x in fds .split ("," , 1 )]
34
- reader = nonblock (reader )
35
- except (KeyError , IndexError , ValueError , IOError ):
28
+ # Open a private copy of reader to avoid setting nonblocking
29
+ # on an unexpecting process with the same reader fd.
30
+ reader = os .open ("/proc/self/fd/%d" % (reader ),
31
+ os .O_RDONLY | os .O_NONBLOCK )
32
+ except (KeyError , IndexError , ValueError , IOError , OSError ) as e :
33
+ print (e , file = sys .stderr )
36
34
# Any missing environment strings or bad fds should result in just
37
35
# using the default specified parallelism.
38
36
print (default )
0 commit comments