- c = (do_profile and [sys.executable, '-m', 'cProfile'] or []) + subcmd
- if not n and not outf and not errf:
- # shortcut when no bup-newliner stuff is needed
- os.execvp(c[0], c)
- else:
- p = subprocess.Popen(c, stdout=outf, stderr=errf,
- preexec_fn=force_tty)
- while 1:
- # if we get a signal while waiting, we have to keep waiting, just
- # in case our child doesn't die.
- ret = p.wait()
- forward_signals = False
- break
- 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()