X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=main.py;h=78da11de049689c7b81736a179d0e4c1a63463f3;hb=6385aa493eff14c7b59aa964ea5cce6f6c3b79a7;hp=ec86b2ac8376c7b4055d36db674b2edd544a531e;hpb=9fc0171c58dd467586f70251228a39a486d35673;p=bup.git diff --git a/main.py b/main.py index ec86b2a..78da11d 100755 --- a/main.py +++ b/main.py @@ -148,10 +148,12 @@ if subcmd_name in ['mux', 'ftp', 'help']: fix_stdout = not already_fixed and os.isatty(1) fix_stderr = not already_fixed and os.isatty(2) -def force_tty(): - if fix_stdout or fix_stderr: - amt = (fix_stdout and 1 or 0) + (fix_stderr and 2 or 0) - os.environ['BUP_FORCE_TTY'] = str(amt) +if fix_stdout or fix_stderr: + tty_env = merge_dict(os.environ, + {'BUP_FORCE_TTY': str((fix_stdout and 1 or 0) + + (fix_stderr and 2 or 0))}) +else: + tty_env = os.environ sep_rx = re.compile(br'([\r\n])') @@ -240,9 +242,7 @@ def run_subcmd(subcmd): 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) + env=tty_env, 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):