Lines 2416-2447
Link Here
|
2416 |
fd_flags[f] = fcntl.fcntl(f.fileno(), fcntl.F_GETFL) |
2416 |
fd_flags[f] = fcntl.fcntl(f.fileno(), fcntl.F_GETFL) |
2417 |
buffsize = 65536 |
2417 |
buffsize = 65536 |
2418 |
eof = False |
2418 |
eof = False |
|
|
2419 |
# Use non-blocking mode to prevent read |
2420 |
# calls from blocking indefinitely. |
2421 |
try: |
2422 |
fcntl.fcntl(master_file.fileno(), fcntl.F_SETFL, |
2423 |
fd_flags[master_file] | os.O_NONBLOCK) |
2424 |
except EnvironmentError, e: |
2425 |
if e.errno != errno.EAGAIN: |
2426 |
raise |
2427 |
del e |
2428 |
# The EAGAIN error signals eof on FreeBSD. |
2429 |
eof = True |
2419 |
while not eof: |
2430 |
while not eof: |
2420 |
events = select.select(iwtd, owtd, ewtd) |
2431 |
events = select.select(iwtd, owtd, ewtd) |
2421 |
for f in events[0]: |
2432 |
for f in events[0]: |
2422 |
# Use non-blocking mode to prevent read |
|
|
2423 |
# calls from blocking indefinitely. |
2424 |
try: |
2425 |
fcntl.fcntl(f.fileno(), fcntl.F_SETFL, |
2426 |
fd_flags[f] | os.O_NONBLOCK) |
2427 |
except EnvironmentError, e: |
2428 |
if e.errno != errno.EAGAIN: |
2429 |
raise |
2430 |
del e |
2431 |
# The EAGAIN error signals eof on FreeBSD. |
2432 |
eof = True |
2433 |
break |
2434 |
buf = array.array('B') |
2433 |
buf = array.array('B') |
2435 |
try: |
2434 |
try: |
2436 |
buf.fromfile(f, buffsize) |
2435 |
buf.fromfile(f, buffsize) |
2437 |
except EOFError: |
2436 |
except EOFError: |
2438 |
pass |
2437 |
pass |
2439 |
fcntl.fcntl(f.fileno(), fcntl.F_SETFL, fd_flags[f]) |
|
|
2440 |
if not buf: |
2438 |
if not buf: |
2441 |
eof = True |
2439 |
eof = True |
2442 |
break |
2440 |
break |
2443 |
# Use blocking mode for writes since we'd rather block than |
|
|
2444 |
# trigger a EWOULDBLOCK error. |
2445 |
if f is master_file: |
2441 |
if f is master_file: |
2446 |
buf.tofile(stdout_file) |
2442 |
buf.tofile(stdout_file) |
2447 |
stdout_file.flush() |
2443 |
stdout_file.flush() |