diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-01-15 13:22:15 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-01-15 13:22:15 -0800 |
commit | e2a3237b4018e274350488868577c4d74a496b85 (patch) | |
tree | 63b430077d0ed8ca07ee87e82a506269ced09948 | |
parent | f680d640ec0bf92ab5506090ee662338b4276ab7 (diff) | |
download | portage-e2a3237b4018e274350488868577c4d74a496b85.tar.gz portage-e2a3237b4018e274350488868577c4d74a496b85.tar.bz2 portage-e2a3237b4018e274350488868577c4d74a496b85.zip |
When killed by signal, return 128 + signum.
This is the same convention that bash uses for returncodes of
processes that are killed by signals.
-rwxr-xr-x | bin/ebuild | 8 | ||||
-rwxr-xr-x | bin/egencache | 8 | ||||
-rwxr-xr-x | bin/emerge | 8 | ||||
-rwxr-xr-x | bin/portageq | 8 | ||||
-rwxr-xr-x | bin/repoman | 8 | ||||
-rw-r--r-- | pym/_emerge/main.py | 4 |
6 files changed, 23 insertions, 21 deletions
diff --git a/bin/ebuild b/bin/ebuild index b57215fa7..2c04200e7 100755 --- a/bin/ebuild +++ b/bin/ebuild @@ -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 diff --git a/bin/egencache b/bin/egencache index c01ced058..2fb30a07c 100755 --- a/bin/egencache +++ b/bin/egencache @@ -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 diff --git a/bin/emerge b/bin/emerge index 5d74bfa00..6f69244be 100755 --- a/bin/emerge +++ b/bin/emerge @@ -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 diff --git a/bin/portageq b/bin/portageq index 547a70d6c..2f254ca81 100755 --- a/bin/portageq +++ b/bin/portageq @@ -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 diff --git a/bin/repoman b/bin/repoman index 185540d35..60c69fb59 100755 --- a/bin/repoman +++ b/bin/repoman @@ -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) diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index 912fab51b..95174ccc0 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -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) |