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