- ret = p.wait()
- break
- except SigException, e:
- log('\nbup: %s\n' % e)
- os.kill(p.pid, e.signum)
- ret = 94
- except OSError, e:
- log('%s: %s\n' % (subcmd[0], e))
- ret = 98
-finally:
- if p and p.poll() == None:
- os.kill(p.pid, signal.SIGTERM)
- p.wait()
- if n:
- n.stdin.close()
+ print_clean_line(dest, pending_items, width)
+ except (EnvironmentError, EOFError) as ex:
+ pending_ex = chain_ex(add_ex_tb(ex), pending_ex)
+ except BaseException as ex:
+ pending_ex = chain_ex(add_ex_tb(ex), pending_ex)
+ if pending_ex:
+ raise pending_ex
+
+def run_subcmd(subcmd):
+
+ c = (do_profile and [sys.executable, '-m', 'cProfile'] or []) + subcmd
+ if not (fix_stdout or fix_stderr):
+ os.execvp(c[0], c)
+
+ p = None
+ try:
+ p = subprocess.Popen(c,
+ stdout=PIPE if fix_stdout else sys.stdout,
+ stderr=PIPE if fix_stderr else sys.stderr,
+ preexec_fn=force_tty,
+ bufsize=4096,
+ close_fds=True)
+ # Assume p will receive these signals and quit, which will
+ # then cause us to quit.
+ for sig in (signal.SIGINT, signal.SIGTERM, signal.SIGQUIT):
+ signal.signal(sig, signal.SIG_IGN)
+
+ filter_output(fix_stdout and p.stdout.fileno() or None,
+ fix_stderr and p.stderr.fileno() or None,
+ fix_stdout and sys.stdout.fileno() or None,
+ fix_stderr and sys.stderr.fileno() or None)
+ return p.wait()
+ except BaseException as ex:
+ add_ex_tb(ex)