X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=blobdiff_plain;f=main.py;h=50eb24454154b216287563e1ad5c773d27bb24b9;hp=4d8ea1f3547260dd293590de64ae4317eadff301;hb=b7a524ccb662c9ed3ebd786da0f45f459929ef45;hpb=dbc9e3ec44b765860e7769d2084c609dfa246230 diff --git a/main.py b/main.py index 4d8ea1f..50eb244 100755 --- a/main.py +++ b/main.py @@ -93,6 +93,7 @@ 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) + os.setsid() # make sure ctrl-c is sent just to us, not to child too if fix_stdout or fix_stderr: realf = fix_stderr and 2 or 1 @@ -108,15 +109,18 @@ else: class SigException(Exception): - pass + def __init__(self, signum): + self.signum = signum + Exception.__init__(self, 'signal %d received' % signum) def handler(signum, frame): - raise SigException('signal %d received' % signum) + raise SigException(signum) signal.signal(signal.SIGTERM, handler) signal.signal(signal.SIGINT, handler) ret = 95 p = None +killsig = signal.SIGTERM try: try: p = subprocess.Popen([subpath(subcmd)] + argv[2:], @@ -126,10 +130,12 @@ try: log('%s: %s\n' % (subpath(subcmd), e)) ret = 98 except SigException, e: + log('\nbup: %s\n' % e) + killsig = e.signum ret = 94 finally: if p and p.poll() == None: - os.kill(p.pid, signal.SIGTERM) + os.kill(p.pid, killsig) p.wait() if n: n.stdin.close()