Lines 2426-2433
Link Here
|
2426 |
|
2426 |
|
2427 |
if buf: |
2427 |
if buf: |
2428 |
if not self.background: |
2428 |
if not self.background: |
2429 |
buf.tofile(files.stdout) |
2429 |
write_successful = False |
2430 |
files.stdout.flush() |
2430 |
failures = 0 |
|
|
2431 |
while True: |
2432 |
try: |
2433 |
if not write_successful: |
2434 |
buf.tofile(files.stdout) |
2435 |
write_successful = True |
2436 |
files.stdout.flush() |
2437 |
break |
2438 |
except IOError, e: |
2439 |
if e.errno != errno.EAGAIN: |
2440 |
raise |
2441 |
del e |
2442 |
failures += 1 |
2443 |
if failures > 50: |
2444 |
# Avoid a potentially infinite loop. In |
2445 |
# most cases, the failure count is zero |
2446 |
# and it's unlikely to exceed 1. |
2447 |
raise |
2448 |
|
2449 |
# This means that a subprocess has put an inherited |
2450 |
# stdio file descriptor (typically stdin) into |
2451 |
# O_NONBLOCK mode. This is not acceptable (see bug |
2452 |
# #264435), so revert it. We need to use a loop |
2453 |
# here since there's a race condition due to |
2454 |
# parallel processes being able to change the |
2455 |
# flags on the inherited file descriptor. |
2456 |
# TODO: When possible, avoid having child processes |
2457 |
# inherit stdio file descriptors from portage |
2458 |
# (maybe it can't be avoided with |
2459 |
# PROPERTIES=interactive). |
2460 |
fcntl.fcntl(files.stdout.fileno(), fcntl.F_SETFL, |
2461 |
fcntl.fcntl(files.stdout.fileno(), |
2462 |
fcntl.F_GETFL) ^ os.O_NONBLOCK) |
2463 |
|
2431 |
buf.tofile(files.log) |
2464 |
buf.tofile(files.log) |
2432 |
files.log.flush() |
2465 |
files.log.flush() |
2433 |
else: |
2466 |
else: |