From 9a5f9cf8f6a8ff78cc124c40aaebcedd7be8d059 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 13 Aug 2010 07:47:56 -0700 Subject: [PATCH] Bug #278895 - After EbuildIpcDaemon identifies an ebuild process that has left an orphan child process running in the background, generate an eerror message about a 'zombie' process and note the pid. --- pym/_emerge/AbstractEbuildProcess.py | 10 ++++++++++ pym/_emerge/SubProcess.py | 19 ++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) 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. -- 2.26.2