Show More
@@ -8,6 +8,7 | |||
|
8 | 8 | from i18n import _ |
|
9 | 9 | import encoding |
|
10 | 10 | import os, sys, errno, stat, getpass, pwd, grp, socket, tempfile, unicodedata |
|
11 | import fcntl | |
|
11 | 12 | |
|
12 | 13 | posixfile = open |
|
13 | 14 | normpath = os.path.normpath |
@@ -432,7 +433,7 def gethgcmd(): | |||
|
432 | 433 | |
|
433 | 434 | def termwidth(): |
|
434 | 435 | try: |
|
435 |
import termios, array |
|
|
436 | import termios, array | |
|
436 | 437 | for dev in (sys.stderr, sys.stdout, sys.stdin): |
|
437 | 438 | try: |
|
438 | 439 | try: |
@@ -570,13 +571,24 def statisexec(st): | |||
|
570 | 571 | |
|
571 | 572 | def readpipe(pipe): |
|
572 | 573 | """Read all available data from a pipe.""" |
|
574 | # We can't fstat() a pipe because Linux will always report 0. | |
|
575 | # So, we set the pipe to non-blocking mode and read everything | |
|
576 | # that's available. | |
|
577 | flags = fcntl.fcntl(pipe, fcntl.F_GETFL) | |
|
578 | flags |= os.O_NONBLOCK | |
|
579 | oldflags = fcntl.fcntl(pipe, fcntl.F_SETFL, flags) | |
|
580 | ||
|
581 | try: | |
|
573 | 582 | chunks = [] |
|
574 | 583 | while True: |
|
575 | size = os.fstat(pipe.fileno()).st_size | |
|
576 | if not size: | |
|
577 | break | |
|
578 | ||
|
579 | s = pipe.read(size) | |
|
584 | try: | |
|
585 | s = pipe.read() | |
|
580 | 586 | if not s: |
|
581 | 587 | break |
|
582 | 588 | chunks.append(s) |
|
589 | except IOError: | |
|
590 | break | |
|
591 | ||
|
592 | return ''.join(chunks) | |
|
593 | finally: | |
|
594 | fcntl.fcntl(pipe, fcntl.F_SETFL, oldflags) |
General Comments 0
You need to be logged in to leave comments.
Login now