Gentoo Archives: gentoo-commits

From: Brian Dolbec <dolsen@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/catalyst:pending commit in: bin/, catalyst/base/
Date: Thu, 09 Mar 2017 10:02:36
Message-Id: 1489053573.106c588e852927d244df2a9b66d188c60252e31d.dolsen@gentoo
1 commit: 106c588e852927d244df2a9b66d188c60252e31d
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Tue Sep 8 06:15:25 2015 +0000
4 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
5 CommitDate: Thu Mar 9 09:59:33 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=106c588e
7
8 Move the signal handler into the StageBase class so it can handle unbind() cleanup
9
10 Not quite complete, still errors on some unmounting
11
12 bin/catalyst | 19 -------------------
13 catalyst/base/stagebase.py | 19 +++++++++++++++++++
14 2 files changed, 19 insertions(+), 19 deletions(-)
15
16 diff --git a/bin/catalyst b/bin/catalyst
17 index 72a4cb4..a64cfce 100755
18 --- a/bin/catalyst
19 +++ b/bin/catalyst
20 @@ -12,25 +12,6 @@ from __future__ import print_function
21
22 import sys
23
24 -# This block ensures that ^C interrupts are handled quietly.
25 -try:
26 - import signal
27 -
28 - def exithandler(_signum, _frame):
29 - signal.signal(signal.SIGINT, signal.SIG_IGN)
30 - signal.signal(signal.SIGTERM, signal.SIG_IGN)
31 - print()
32 - sys.exit(1)
33 -
34 - signal.signal(signal.SIGINT, exithandler)
35 - signal.signal(signal.SIGTERM, exithandler)
36 - signal.signal(signal.SIGPIPE, signal.SIG_DFL)
37 -
38 -except KeyboardInterrupt:
39 - print()
40 - sys.exit(1)
41 -
42 -
43 from catalyst.main import main
44
45 try:
46
47 diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
48 index b857a64..eed1458 100644
49 --- a/catalyst/base/stagebase.py
50 +++ b/catalyst/base/stagebase.py
51 @@ -2,6 +2,7 @@
52 import os
53 import imp
54 import shutil
55 +import signal
56 import sys
57
58 from snakeoil import fileutils
59 @@ -206,6 +207,17 @@ class StageBase(TargetBase, ClearBase, GenBase):
60 if "portage_confdir" in self.settings:
61 file_locate(self.settings, ["portage_confdir"], expand = 0)
62
63 +
64 + # This block ensures that ^C interrupts are handled quietly.
65 + try:
66 + signal.signal(signal.SIGINT, self.exithandler)
67 + signal.signal(signal.SIGTERM, self.exithandler)
68 + signal.signal(signal.SIGPIPE, signal.SIG_DFL)
69 +
70 + except KeyboardInterrupt:
71 + print()
72 + sys.exit(1)
73 +
74 # Setup our mount points.
75 # initialize our target mounts.
76 self.target_mounts = TARGET_MOUNT_DEFAULTS.copy()
77 @@ -268,6 +280,13 @@ class StageBase(TargetBase, ClearBase, GenBase):
78 self.env["PORT_LOGDIR"] = self.settings["port_logdir"]
79 self.env["PORT_LOGDIR_CLEAN"] = PORT_LOGDIR_CLEAN
80
81 + def exithandler(self, _signum, _frame):
82 + signal.signal(signal.SIGINT, signal.SIG_IGN)
83 + signal.signal(signal.SIGTERM, signal.SIG_IGN)
84 + self.unbind()
85 + print()
86 + sys.exit(1)
87 +
88 def override_cbuild(self):
89 if "CBUILD" in self.makeconf:
90 self.settings["CBUILD"] = self.makeconf["CBUILD"]