From: Zac Medico Date: Mon, 9 Sep 2013 16:49:39 +0000 (-0700) Subject: Handle EPERM from os.kill(), bug #358211. X-Git-Tag: v2.2.2~4 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2cd7f834919be0d9549bbe5d8f712e03ce95d5eb;p=portage.git Handle EPERM from os.kill(), bug #358211. --- diff --git a/pym/_emerge/SpawnProcess.py b/pym/_emerge/SpawnProcess.py index 021e54616..6024ef779 100644 --- a/pym/_emerge/SpawnProcess.py +++ b/pym/_emerge/SpawnProcess.py @@ -8,6 +8,7 @@ except ImportError: fcntl = None import errno +import logging import platform import signal import sys @@ -16,6 +17,7 @@ from _emerge.SubProcess import SubProcess import portage from portage import os from portage.const import BASH_BINARY +from portage.util import writemsg_level from portage.util._async.PipeLogger import PipeLogger # On Darwin, FD_CLOEXEC triggers errno 35 for stdout (bug #456296) @@ -198,7 +200,13 @@ class SpawnProcess(SubProcess): try: os.kill(int(p), sig) except OSError as e: - if e.errno != errno.ESRCH: + if e.errno == errno.EPERM: + # Reported with hardened kernel (bug #358211). + writemsg_level( + "!!! kill: (%i) - Operation not permitted\n" % + (p,), level=logging.ERROR, + noiselevel=-1) + elif e.errno != errno.ESRCH: raise # step 1: kill all orphans diff --git a/pym/_emerge/SubProcess.py b/pym/_emerge/SubProcess.py index 4ccf9164f..13d938297 100644 --- a/pym/_emerge/SubProcess.py +++ b/pym/_emerge/SubProcess.py @@ -1,7 +1,10 @@ # Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +import logging + from portage import os +from portage.util import writemsg_level from _emerge.AbstractPollTask import AbstractPollTask import signal import errno @@ -45,7 +48,13 @@ class SubProcess(AbstractPollTask): try: os.kill(self.pid, signal.SIGTERM) except OSError as e: - if e.errno != errno.ESRCH: + if e.errno == errno.EPERM: + # Reported with hardened kernel (bug #358211). + writemsg_level( + "!!! kill: (%i) - Operation not permitted\n" % + (self.pid,), level=logging.ERROR, + noiselevel=-1) + elif e.errno != errno.ESRCH: raise def isAlive(self): @@ -64,7 +73,13 @@ class SubProcess(AbstractPollTask): try: os.kill(self.pid, signal.SIGKILL) except OSError as e: - if e.errno != errno.ESRCH: + if e.errno == errno.EPERM: + # Reported with hardened kernel (bug #358211). + writemsg_level( + "!!! kill: (%i) - Operation not permitted\n" % + (self.pid,), level=logging.ERROR, + noiselevel=-1) + elif e.errno != errno.ESRCH: raise del e self._wait_loop(timeout=self._cancel_timeout)