summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/_emerge/AbstractEbuildProcess.py10
-rw-r--r--pym/_emerge/SubProcess.py19
2 files changed, 28 insertions, 1 deletions
diff --git a/pym/_emerge/AbstractEbuildProcess.py b/pym/_emerge/AbstractEbuildProcess.py
index 913a32d12..c3f539dcd 100644
--- a/pym/_emerge/AbstractEbuildProcess.py
+++ b/pym/_emerge/AbstractEbuildProcess.py
@@ -60,6 +60,16 @@ class AbstractEbuildProcess(SpawnProcess):
# being killed by a signal.
self.cancel()
+ def _zombie(self):
+ phase = self._get_phase()
+
+ msg = _("The ebuild phase '%s' appears "
+ "to have left a zombie process with "
+ "pid %d.") % (phase, self.pid)
+
+ for l in textwrap.wrap(msg, 72):
+ eerror(l, phase=phase, key=self.settings.mycpv)
+
def _pipe(self, fd_pipes):
stdout_pipe = fd_pipes.get(1)
got_pty, master_fd, slave_fd = \
diff --git a/pym/_emerge/SubProcess.py b/pym/_emerge/SubProcess.py
index b1b5201eb..b6489c393 100644
--- a/pym/_emerge/SubProcess.py
+++ b/pym/_emerge/SubProcess.py
@@ -61,7 +61,21 @@ class SubProcess(AbstractPollTask):
return self.returncode
if self._registered:
- self.scheduler.schedule(self._reg_id)
+ if self.cancelled:
+ timeout = 1000
+ self.scheduler.schedule(self._reg_id, timeout=timeout)
+ if self._registered:
+ try:
+ os.kill(self.pid, signal.SIGKILL)
+ except OSError as e:
+ if e.errno != errno.ESRCH:
+ raise
+ del e
+ self.scheduler.schedule(self._reg_id, timeout=timeout)
+ if self._registered:
+ self._zombie()
+ else:
+ self.scheduler.schedule(self._reg_id)
self._unregister()
if self.returncode is not None:
return self.returncode
@@ -78,6 +92,9 @@ class SubProcess(AbstractPollTask):
return self.returncode
+ def _zombie(self):
+ pass
+
def _unregister(self):
"""
Unregister from the scheduler and close open files.