When killed by signal, return 128 + signum.
authorZac Medico <zmedico@gentoo.org>
Sat, 15 Jan 2011 21:22:15 +0000 (13:22 -0800)
committerZac Medico <zmedico@gentoo.org>
Sat, 15 Jan 2011 21:22:15 +0000 (13:22 -0800)
This is the same convention that bash uses for returncodes of
processes that are killed by signals.

bin/ebuild
bin/egencache
bin/emerge
bin/portageq
bin/repoman
pym/_emerge/main.py

index b57215fa78da9ae1597ebf8b90a8a224d33a075c..2c04200e7842a132a223bc58af751c30a86bfb77 100755 (executable)
@@ -1,18 +1,18 @@
 #!/usr/bin/python -O
-# Copyright 1999-2010 Gentoo Foundation
+# Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import print_function
 
+import signal
 import sys
 # This block ensures that ^C interrupts are handled quietly.
 try:
-       import signal
 
        def exithandler(signum,frame):
                signal.signal(signal.SIGINT, signal.SIG_IGN)
                signal.signal(signal.SIGTERM, signal.SIG_IGN)
-               sys.exit(1)
+               sys.exit(128 + signum)
 
        signal.signal(signal.SIGINT, exithandler)
        signal.signal(signal.SIGTERM, exithandler)
@@ -21,7 +21,7 @@ try:
        signal.signal(signal.SIGPIPE, signal.SIG_DFL)
 
 except KeyboardInterrupt:
-       sys.exit(1)
+       sys.exit(128 + signal.SIGINT)
 
 def debug_signal(signum, frame):
        import pdb
index c01ced0583b9d74c6ee5667c7388edc6a94ce9e4..2fb30a07c586c155bbcdcd101d44aaf7c34e7699 100755 (executable)
@@ -1,24 +1,24 @@
 #!/usr/bin/python
-# Copyright 2009-2010 Gentoo Foundation
+# Copyright 2009-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import print_function
 
+import signal
 import sys
 # This block ensures that ^C interrupts are handled quietly.
 try:
-       import signal
 
        def exithandler(signum,frame):
                signal.signal(signal.SIGINT, signal.SIG_IGN)
                signal.signal(signal.SIGTERM, signal.SIG_IGN)
-               sys.exit(1)
+               sys.exit(128 + signum)
 
        signal.signal(signal.SIGINT, exithandler)
        signal.signal(signal.SIGTERM, exithandler)
 
 except KeyboardInterrupt:
-       sys.exit(1)
+       sys.exit(128 + signal.SIGINT)
 
 import codecs
 import logging
index 5d74bfa00d760dd4be8f3c7638dc9336daa980ab..6f69244be90a168c5a9e0fe9bfecc9061464a586 100755 (executable)
@@ -1,18 +1,18 @@
 #!/usr/bin/python
-# Copyright 2006-2009 Gentoo Foundation
+# Copyright 2006-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import print_function
 
+import signal
 import sys
 # This block ensures that ^C interrupts are handled quietly.
 try:
-       import signal
 
        def exithandler(signum,frame):
                signal.signal(signal.SIGINT, signal.SIG_IGN)
                signal.signal(signal.SIGTERM, signal.SIG_IGN)
-               sys.exit(1)
+               sys.exit(128 + signum)
 
        signal.signal(signal.SIGINT, exithandler)
        signal.signal(signal.SIGTERM, exithandler)
@@ -21,7 +21,7 @@ try:
        signal.signal(signal.SIGPIPE, signal.SIG_DFL)
 
 except KeyboardInterrupt:
-       sys.exit(1)
+       sys.exit(128 + signal.SIGINT)
 
 def debug_signal(signum, frame):
        import pdb
index 547a70d6c6f8d78bbd4741d4d1587c5376c58358..2f254ca81d59a4ff4dbdce31c57fd9a2f917a5f2 100755 (executable)
@@ -1,24 +1,24 @@
 #!/usr/bin/python -O
-# Copyright 1999-2006 Gentoo Foundation
+# Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import print_function
 
+import signal
 import sys
 # This block ensures that ^C interrupts are handled quietly.
 try:
-       import signal
 
        def exithandler(signum, frame):
                signal.signal(signal.SIGINT, signal.SIG_IGN)
                signal.signal(signal.SIGTERM, signal.SIG_IGN)
-               sys.exit(1)
+               sys.exit(128 + signum)
 
        signal.signal(signal.SIGINT, exithandler)
        signal.signal(signal.SIGTERM, exithandler)
 
 except KeyboardInterrupt:
-       sys.exit(1)
+       sys.exit(128 + signal.SIGINT)
 
 import os
 import subprocess
index 185540d3546587380ffad215bf5abf990aa3c963..60c69fb599812153b99f89391c2473166687e4b5 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/python -O
-# Copyright 1999-2010 Gentoo Foundation
+# Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 # Next to do: dep syntax checking in mask files
@@ -113,8 +113,10 @@ def err(txt):
 
 def exithandler(signum=None, frame=None):
        logging.fatal("Interrupted; exiting...")
-       sys.exit(1)
-       os.kill(0, signal.SIGKILL)
+       if signum is None:
+               sys.exit(1)
+       else:
+               sys.exit(128 + signum)
 
 signal.signal(signal.SIGINT,exithandler)
 
index 912fab51b7346367ee6f5a46f4ae6a613f73b09e..95174ccc01df573a155398d6e234e297ae8b12f1 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 1999-2010 Gentoo Foundation
+# Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import print_function
@@ -1586,7 +1586,7 @@ def emerge_main():
                signal.signal(signal.SIGINT, signal.SIG_IGN)
                signal.signal(signal.SIGTERM, signal.SIG_IGN)
                portage.util.writemsg("\n\nExiting on signal %(signal)s\n" % {"signal":signum})
-               sys.exit(100+signum)
+               sys.exit(128 + signum)
        signal.signal(signal.SIGINT, emergeexitsig)
        signal.signal(signal.SIGTERM, emergeexitsig)