]> arthur.barton.de Git - bup.git/commitdiff
main.py: forward SIGTSTP/SIGCONT so "C-z" will actually suspend everything.
authorRob Browning <rlb@defaultvalue.org>
Fri, 23 Aug 2013 17:23:17 +0000 (12:23 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sun, 25 Aug 2013 18:22:03 +0000 (13:22 -0500)
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 <rlb@defaultvalue.org>
lib/bup/helpers.py
main.py

index ef2e368e2f4875d3eb362d237720e329b52cd09a..afbf18daa8e402395edaf9afa0117a50e34f3576 100644 (file)
@@ -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 3554179d4c5a5272b2c6ec2960443fc528a30ab5..0eb7260c75e83ee9311e59a46408a18dceb3f3d8 100755 (executable)
--- 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))