]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
bitbake: runqueue: Improve sigchld handler
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 11 Mar 2014 18:09:37 +0000 (18:09 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 12 Mar 2014 12:58:48 +0000 (05:58 -0700)
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>
bitbake/lib/bb/runqueue.py

index 6650bd86376c209014f547ffdc3a76da017667d8..a30f594e44fbdf0c7760745533929462d3415530 100644 (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