bitbake: runqueue: Improve sigchld handler

The sigchld handler was reaping any processes and this was leading to
confusion with any other process handling code that could be active.
This patch:

a) Ensures we only read any process results for the worker processes
   we want to monitor
b) Ensures we pass the event to any other sigchld handler if
   it isn't an event we're interested in so the functions are properly
   chained.

Together this should resolve some of the reports of unknown processes
people have been reporting.

(Bitbake rev: fe8baaa2f533db7a1b7203476c675588923d8d45)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2014-03-11 18:09:37 +00:00
parent 1960f6b2ec
commit 9104a32196

View File

@@ -856,6 +856,7 @@ class RunQueue:
self.workerpipe = None
self.fakeworker = None
self.fakeworkerpipe = None
self.oldsigchld = None
def _start_worker(self, fakeroot = False, rqexec = None):
logger.debug(1, "Starting bitbake-worker")
@@ -912,11 +913,12 @@ class RunQueue:
continue
workerpipe.close()
def sigchild_exception(self, signum, stackframe):
pid = True
while pid:
def sigchild_exception(self, *args, **kwargs):
for w in [self.worker, self.fakeworker]:
if not w:
continue
try:
pid, status = os.waitpid(-1, os.WNOHANG)
pid, status = os.waitpid(w.pid, os.WNOHANG)
if pid != 0 and not self.teardown:
if self.worker and pid == self.worker.pid:
name = "Worker"
@@ -928,11 +930,14 @@ class RunQueue:
self.finish_runqueue(True)
except OSError:
pid = False
if callable(self.oldsigchld):
self.oldsigchld(*args, **kwargs)
def start_worker(self):
if self.worker:
self.teardown_workers()
self.teardown = False
self.oldsigchld = signal.getsignal(signal.SIGCHLD)
signal.signal(signal.SIGCHLD, self.sigchild_exception)
self.worker, self.workerpipe = self._start_worker()
@@ -942,7 +947,7 @@ class RunQueue:
def teardown_workers(self):
self.teardown = True
signal.signal(signal.SIGCHLD, signal.SIG_DFL)
signal.signal(signal.SIGCHLD, self.oldsigchld)
self._teardown_worker(self.worker, self.workerpipe)
self.worker = None
self.workerpipe = None