From: Richard Purdie Date: Tue, 11 Mar 2014 18:09:37 +0000 (+0000) Subject: runqueue: Improve sigchld handler X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fe8baaa2f533db7a1b7203476c675588923d8d45;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git 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. Signed-off-by: Richard Purdie --- diff --git a/lib/bb/runqueue.py b/lib/bb/runqueue.py index 6650bd86376..a30f594e44f 100644 --- a/lib/bb/runqueue.py +++ b/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