From 9104a32196405a4bf5312eccdc0d4a207f8bf9f1 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Tue, 11 Mar 2014 18:09:37 +0000 Subject: 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 --- bitbake/lib/bb/runqueue.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'bitbake/lib/bb/runqueue.py') diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py index 6650bd8637..a30f594e44 100644 --- a/bitbake/lib/bb/runqueue.py +++ b/bitbake/lib/bb/runqueue.py @@ -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 -- cgit v1.2.3-54-g00ecf