diff options
Diffstat (limited to 'subcmds')
-rw-r--r-- | subcmds/forall.py | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/subcmds/forall.py b/subcmds/forall.py index 07ee8d58..2c12c55f 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.py | |||
@@ -15,17 +15,16 @@ | |||
15 | 15 | ||
16 | from __future__ import print_function | 16 | from __future__ import print_function |
17 | import errno | 17 | import errno |
18 | import fcntl | ||
19 | import multiprocessing | 18 | import multiprocessing |
20 | import re | 19 | import re |
21 | import os | 20 | import os |
22 | import select | ||
23 | import signal | 21 | import signal |
24 | import sys | 22 | import sys |
25 | import subprocess | 23 | import subprocess |
26 | 24 | ||
27 | from color import Coloring | 25 | from color import Coloring |
28 | from command import Command, MirrorSafeCommand | 26 | from command import Command, MirrorSafeCommand |
27 | import platform_utils | ||
29 | 28 | ||
30 | _CAN_COLOR = [ | 29 | _CAN_COLOR = [ |
31 | 'branch', | 30 | 'branch', |
@@ -344,35 +343,25 @@ def DoWork(project, mirror, opt, cmd, shell, cnt, config): | |||
344 | if opt.project_header: | 343 | if opt.project_header: |
345 | out = ForallColoring(config) | 344 | out = ForallColoring(config) |
346 | out.redirect(sys.stdout) | 345 | out.redirect(sys.stdout) |
347 | class sfd(object): | ||
348 | def __init__(self, fd, dest): | ||
349 | self.fd = fd | ||
350 | self.dest = dest | ||
351 | def fileno(self): | ||
352 | return self.fd.fileno() | ||
353 | |||
354 | empty = True | 346 | empty = True |
355 | errbuf = '' | 347 | errbuf = '' |
356 | 348 | ||
357 | p.stdin.close() | 349 | p.stdin.close() |
358 | s_in = [sfd(p.stdout, sys.stdout), | 350 | s_in = platform_utils.FileDescriptorStreams.create() |
359 | sfd(p.stderr, sys.stderr)] | 351 | s_in.add(p.stdout, sys.stdout, 'stdout') |
360 | 352 | s_in.add(p.stderr, sys.stderr, 'stderr') | |
361 | for s in s_in: | ||
362 | flags = fcntl.fcntl(s.fd, fcntl.F_GETFL) | ||
363 | fcntl.fcntl(s.fd, fcntl.F_SETFL, flags | os.O_NONBLOCK) | ||
364 | 353 | ||
365 | while s_in: | 354 | while not s_in.is_done: |
366 | in_ready, _out_ready, _err_ready = select.select(s_in, [], []) | 355 | in_ready = s_in.select() |
367 | for s in in_ready: | 356 | for s in in_ready: |
368 | buf = s.fd.read(4096) | 357 | buf = s.read() |
369 | if not buf: | 358 | if not buf: |
370 | s.fd.close() | 359 | s.close() |
371 | s_in.remove(s) | 360 | s_in.remove(s) |
372 | continue | 361 | continue |
373 | 362 | ||
374 | if not opt.verbose: | 363 | if not opt.verbose: |
375 | if s.fd != p.stdout: | 364 | if s.std_name == 'stderr': |
376 | errbuf += buf | 365 | errbuf += buf |
377 | continue | 366 | continue |
378 | 367 | ||