From: Brian Dolbec <dolsen@gentoo.org>
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
Date: Fri, 10 Mar 2017 11:22:47 -0800 [thread overview]
Message-ID: <20170310112247.1c8fff5d.dolsen@gentoo.org> (raw)
From 106c588e852927d244df2a9b66d188c60252e31d Mon Sep 17 00:00:00 2001
From: Brian Dolbec <dolsen@gentoo.org>
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
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 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
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"]
--
2.12.0
--
Brian Dolbec <dolsen>
next prev reply other threads:[~2017-03-10 19:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-10 19:22 [gentoo-catalyst] [PATCH 0/7] Latest pending branch fixes Brian Dolbec
2017-03-10 19:22 ` Brian Dolbec [this message]
2017-03-11 21:31 ` [gentoo-catalyst] [PATCH 1/7] Move the signal handler into the StageBase class so it can handle unbind() cleanup Mike Frysinger
2017-03-10 19:23 ` [gentoo-catalyst] [PATCH 6/7] defaults.py: Update all repository, DISTDIR, PKGDIR settings to new /var paths Brian Dolbec
2017-03-10 19:51 ` Zac Medico
2017-03-10 20:36 ` Brian Dolbec
2017-03-10 21:02 ` Brian Dolbec
2017-03-20 9:02 ` Mike Frysinger
2017-03-20 9:21 ` Brian Dolbec
2017-03-20 9:32 ` Mike Frysinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170310112247.1c8fff5d.dolsen@gentoo.org \
--to=dolsen@gentoo.org \
--cc=gentoo-catalyst@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox