From aa6f2c87e6f1292f1fa22f618532b65a5565d604 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Fri, 23 Aug 2013 12:23:17 -0500 Subject: [PATCH] main.py: forward SIGTSTP/SIGCONT so "C-z" will actually suspend everything. Catch and forward SIGTSTP (as SIGSTOP) and SIGCONT to the subprocess as we already do for SIGTERM and SIGINT so that the subprocess will also suspend/resume. This still leaves bup with potentially unexpected behavior since the (detached) subprocess will never see a SIGSTOP delivered to the parent (because SIGSTOP can't be intercepted and forwarded). This is due to the os.setsid() call that was originally introduced to support current newliner arrangement (cf. b7a524ccb662c9ed3ebd786da0f45f459929ef45). Thanks to Kalle for the report. Reported-by: krichter722@aol.de Signed-off-by: Rob Browning --- lib/bup/helpers.py | 2 +- main.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/bup/helpers.py b/lib/bup/helpers.py index ef2e368..afbf18d 100644 --- a/lib/bup/helpers.py +++ b/lib/bup/helpers.py @@ -667,7 +667,7 @@ def handle_ctrl_c(): oldhook = sys.excepthook def newhook(exctype, value, traceback): if exctype == KeyboardInterrupt: - log('Interrupted.\n') + log('\nInterrupted.\n') else: return oldhook(exctype, value, traceback) sys.excepthook = newhook diff --git a/main.py b/main.py index 3554179..0eb7260 100755 --- a/main.py +++ b/main.py @@ -161,6 +161,8 @@ def handler(signum, frame): signal.signal(signal.SIGTERM, handler) signal.signal(signal.SIGINT, handler) +signal.signal(signal.SIGTSTP, handler) +signal.signal(signal.SIGCONT, handler) ret = 95 p = None @@ -180,8 +182,11 @@ try: ret = p.wait() break except SigException, e: - log('\nbup: %s\n' % e) - os.kill(p.pid, e.signum) + debug1('\nbup: %s\n' % e) + sig = e.signum + if sig == signal.SIGTSTP: + sig = signal.SIGSTOP + os.kill(p.pid, sig) ret = 94 except OSError, e: log('%s: %s\n' % (subcmd[0], e)) -- 2.39.2