From e2a3237b4018e274350488868577c4d74a496b85 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 15 Jan 2011 13:22:15 -0800 Subject: When killed by signal, return 128 + signum. This is the same convention that bash uses for returncodes of processes that are killed by signals. --- bin/ebuild | 8 ++++---- bin/egencache | 8 ++++---- bin/emerge | 8 ++++---- bin/portageq | 8 ++++---- bin/repoman | 8 +++++--- 5 files changed, 21 insertions(+), 19 deletions(-) (limited to 'bin') 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) -- cgit v1.2.3-1-g7c22