summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/egencache10
-rw-r--r--pym/_emerge/Scheduler.py32
-rw-r--r--pym/_emerge/actions.py38
3 files changed, 44 insertions, 36 deletions
diff --git a/bin/egencache b/bin/egencache
index bf729c380..76dd900e7 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -272,15 +272,19 @@ class GenCache(object):
try:
self._regen.run()
-
- if received_signal:
- sys.exit(received_signal[0])
finally:
# Restore previous handlers
if earlier_sigint_handler is not None:
signal.signal(signal.SIGINT, earlier_sigint_handler)
+ else:
+ signal.signal(signal.SIGINT, signal.SIG_DFL)
if earlier_sigterm_handler is not None:
signal.signal(signal.SIGTERM, earlier_sigterm_handler)
+ else:
+ signal.signal(signal.SIGTERM, signal.SIG_DFL)
+
+ if received_signal:
+ sys.exit(received_signal[0])
self.returncode |= self._regen.returncode
cp_missing = self._cp_missing
diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py
index c8301a298..7f38dedc4 100644
--- a/pym/_emerge/Scheduler.py
+++ b/pym/_emerge/Scheduler.py
@@ -7,6 +7,7 @@ import gc
import gzip
import logging
import shutil
+import signal
import sys
import tempfile
import textwrap
@@ -1164,10 +1165,35 @@ class Scheduler(PollScheduler):
return rval
while True:
- rval = self._merge()
- if self._terminated.is_set():
- return 1
+ received_signal = []
+
+ def sighandler(signum, frame):
+ signal.signal(signal.SIGINT, signal.SIG_IGN)
+ signal.signal(signal.SIGTERM, signal.SIG_IGN)
+ portage.util.writemsg("\n\nExiting on signal %(signal)s\n" % \
+ {"signal":signum})
+ self.terminate()
+ received_signal.append(128 + signum)
+
+ earlier_sigint_handler = signal.signal(signal.SIGINT, sighandler)
+ earlier_sigterm_handler = signal.signal(signal.SIGTERM, sighandler)
+
+ try:
+ rval = self._merge()
+ finally:
+ # Restore previous handlers
+ if earlier_sigint_handler is not None:
+ signal.signal(signal.SIGINT, earlier_sigint_handler)
+ else:
+ signal.signal(signal.SIGINT, signal.SIG_DFL)
+ if earlier_sigterm_handler is not None:
+ signal.signal(signal.SIGTERM, earlier_sigterm_handler)
+ else:
+ signal.signal(signal.SIGTERM, signal.SIG_DFL)
+
+ if received_signal:
+ sys.exit(received_signal[0])
if rval == os.EX_OK or fetchonly or not keep_going:
break
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index ab2653e76..1ea2510d2 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -147,7 +147,6 @@ def action_build(settings, trees, mtimedb,
ldpath_mtimes = mtimedb["ldpath"]
favorites=[]
- merge_count = 0
buildpkgonly = "--buildpkgonly" in myopts
pretend = "--pretend" in myopts
fetchonly = "--fetchonly" in myopts or "--fetch-all-uri" in myopts
@@ -435,32 +434,7 @@ def action_build(settings, trees, mtimedb,
del mydepgraph
clear_caches(trees)
- received_signal = []
-
- def emergeexitsig(signum, frame):
- signal.signal(signal.SIGINT, signal.SIG_IGN)
- signal.signal(signal.SIGTERM, signal.SIG_IGN)
- portage.util.writemsg("\n\nExiting on signal %(signal)s\n" % \
- {"signal":signum})
- mergetask.terminate()
- received_signal.append(128 + signum)
-
- earlier_sigint_handler = signal.signal(signal.SIGINT, emergeexitsig)
- earlier_sigterm_handler = signal.signal(signal.SIGTERM, emergeexitsig)
-
- try:
- retval = mergetask.merge()
-
- if received_signal:
- sys.exit(received_signal[0])
- finally:
- # Restore previous handlers
- if earlier_sigint_handler is not None:
- signal.signal(signal.SIGINT, earlier_sigint_handler)
- if earlier_sigterm_handler is not None:
- signal.signal(signal.SIGTERM, earlier_sigterm_handler)
-
- merge_count = mergetask.curval
+ retval = mergetask.merge()
if retval == os.EX_OK and not (buildpkgonly or fetchonly or pretend):
if "yes" == settings.get("AUTOCLEAN"):
@@ -1843,15 +1817,19 @@ def action_regen(settings, portdb, max_jobs, max_load):
try:
regen.run()
-
- if received_signal:
- sys.exit(received_signal[0])
finally:
# Restore previous handlers
if earlier_sigint_handler is not None:
signal.signal(signal.SIGINT, earlier_sigint_handler)
+ else:
+ signal.signal(signal.SIGINT, signal.SIG_DFL)
if earlier_sigterm_handler is not None:
signal.signal(signal.SIGTERM, earlier_sigterm_handler)
+ else:
+ signal.signal(signal.SIGTERM, signal.SIG_DFL)
+
+ if received_signal:
+ sys.exit(received_signal[0])
portage.writemsg_stdout("done!\n")
return regen.returncode