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 AA12B139694 for ; Sat, 11 Mar 2017 07:07:56 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id DE75CE0C30; Sat, 11 Mar 2017 07:07:54 +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 B7B07E0C30 for ; Sat, 11 Mar 2017 07:07:54 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id A59FD340F43 for ; Sat, 11 Mar 2017 07:07:53 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 433886432 for ; Sat, 11 Mar 2017 07:07:52 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1489201108.95931a7137f5eb430b72e2502c1c9815b98cefce.dolsen@gentoo> Subject: [gentoo-commits] proj/catalyst:pending commit in: bin/, catalyst/base/ X-VCS-Repository: proj/catalyst X-VCS-Files: bin/catalyst catalyst/base/stagebase.py X-VCS-Directories: bin/ catalyst/base/ X-VCS-Committer: dolsen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 95931a7137f5eb430b72e2502c1c9815b98cefce X-VCS-Branch: pending Date: Sat, 11 Mar 2017 07:07:52 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: da7cb691-d549-47c6-8112-d9c8fd9170d4 X-Archives-Hash: 0612cce9ae519effa5ceb523e7e86f3a commit: 95931a7137f5eb430b72e2502c1c9815b98cefce Author: Brian Dolbec gentoo org> AuthorDate: Tue Sep 8 06:15:25 2015 +0000 Commit: Brian Dolbec gentoo org> CommitDate: Sat Mar 11 02:58:28 2017 +0000 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=95931a71 Move the signal handler into the StageBase class so it can handle unbind() cleanup 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 72a4cb4..a64cfce 100755 --- a/bin/catalyst +++ b/bin/catalyst @@ -12,25 +12,6 @@ from __future__ import print_function 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) - 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 try: diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index b857a64..eed1458 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 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 = 0) + + # 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 = TARGET_MOUNT_DEFAULTS.copy() @@ -268,6 +280,13 @@ class StageBase(TargetBase, ClearBase, GenBase): self.env["PORT_LOGDIR"] = self.settings["port_logdir"] self.env["PORT_LOGDIR_CLEAN"] = PORT_LOGDIR_CLEAN + 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"] = self.makeconf["CBUILD"]