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>
Sun, 16 Jan 2011 20:33:20 +0000 (12:33 -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 87d974e48a0cac18594e07d5eb78216fd1089e5f..ab88d6a3065dc1cb1f36790e9c5080cb3583cd14 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 3938f49cfbe2b8e6176ca3850631fa1b390fea57..dd2b774e84a1408283caf5a8d963d57b760db8b5 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 e26aa659581cbbeb61ca3c9d900812dba6246b93..40266943f00172499cbbf915c598802d0aeb1c7a 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)