From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 18FE2139694 for ; Fri, 10 Mar 2017 19:22:56 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6E09EE0C33; Fri, 10 Mar 2017 19:22:50 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 45E88E0C33 for ; Fri, 10 Mar 2017 19:22:50 +0000 (UTC) Received: from professor-x (d108-172-194-175.bchsia.telus.net [108.172.194.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: dolsen) by smtp.gentoo.org (Postfix) with ESMTPSA id 8F39234105A for ; Fri, 10 Mar 2017 19:22:49 +0000 (UTC) Date: Fri, 10 Mar 2017 11:22:47 -0800 From: Brian Dolbec To: gentoo-catalyst@lists.gentoo.org Subject: [gentoo-catalyst] [PATCH 1/7] Move the signal handler into the StageBase class so it can handle unbind() cleanup Message-ID: <20170310112247.1c8fff5d.dolsen@gentoo.org> Organization: Gentoo Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-catalyst@lists.gentoo.org Reply-to: gentoo-catalyst@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 8aea64a6-f095-4a1f-81c6-302d3d380013 X-Archives-Hash: 2c8d94f316418600e304d50b6858870a =46rom 106c588e852927d244df2a9b66d188c60252e31d Mon Sep 17 00:00:00 2001 From: Brian Dolbec Date: Mon, 7 Sep 2015 23:15:25 -0700 Subject: [PATCH 1/7] Move the signal handler into the StageBase class so it can handle unbind() cleanup To: gentoo-catalyst@lists.gentoo.org Not quite complete, still errors on some unmounting --- bin/catalyst | 19 ------------------- catalyst/base/stagebase.py | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/bin/catalyst b/bin/catalyst index 72a4cb4d..a64cfce8 100755 --- a/bin/catalyst +++ b/bin/catalyst @@ -12,25 +12,6 @@ from __future__ import print_function =20 import sys =20 -# 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) - print() - sys.exit(1) - - signal.signal(signal.SIGINT, exithandler) - signal.signal(signal.SIGTERM, exithandler) - signal.signal(signal.SIGPIPE, signal.SIG_DFL) - -except KeyboardInterrupt: - print() - sys.exit(1) - - from catalyst.main import main =20 try: diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index b857a64b..eed14589 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -2,6 +2,7 @@ import os import imp import shutil +import signal import sys =20 from snakeoil import fileutils @@ -206,6 +207,17 @@ class StageBase(TargetBase, ClearBase, GenBase): if "portage_confdir" in self.settings: file_locate(self.settings, ["portage_confdir"], expand =3D 0) =20 + + # This block ensures that ^C interrupts are handled quietly. + try: + signal.signal(signal.SIGINT, self.exithandler) + signal.signal(signal.SIGTERM, self.exithandler) + signal.signal(signal.SIGPIPE, signal.SIG_DFL) + + except KeyboardInterrupt: + print() + sys.exit(1) + # Setup our mount points. # initialize our target mounts. self.target_mounts =3D TARGET_MOUNT_DEFAULTS.copy() @@ -268,6 +280,13 @@ class StageBase(TargetBase, ClearBase, GenBase): self.env["PORT_LOGDIR"] =3D self.settings["port_logdir"] self.env["PORT_LOGDIR_CLEAN"] =3D PORT_LOGDIR_CLEAN =20 + def exithandler(self, _signum, _frame): + signal.signal(signal.SIGINT, signal.SIG_IGN) + signal.signal(signal.SIGTERM, signal.SIG_IGN) + self.unbind() + print() + sys.exit(1) + def override_cbuild(self): if "CBUILD" in self.makeconf: self.settings["CBUILD"] =3D self.makeconf["CBUILD"] --=20 2.12.0 --=20 Brian Dolbec