summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/runqueue.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2014-03-11 18:09:37 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-03-12 05:58:48 -0700
commit9104a32196405a4bf5312eccdc0d4a207f8bf9f1 (patch)
tree2a9af39e8aae292d8ff6912e6e5c13ae5d5dfc99 /bitbake/lib/bb/runqueue.py
parent1960f6b2ecbb793b40ebc9aed25c8f9cb7884c9a (diff)
downloadpoky-9104a32196405a4bf5312eccdc0d4a207f8bf9f1.tar.gz
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>
Diffstat (limited to 'bitbake/lib/bb/runqueue.py')
-rw-r--r--bitbake/lib/bb/runqueue.py15
1 files changed, 10 insertions, 5 deletions
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:
856 self.workerpipe = None 856 self.workerpipe = None
857 self.fakeworker = None 857 self.fakeworker = None
858 self.fakeworkerpipe = None 858 self.fakeworkerpipe = None
859 self.oldsigchld = None
859 860
860 def _start_worker(self, fakeroot = False, rqexec = None): 861 def _start_worker(self, fakeroot = False, rqexec = None):
861 logger.debug(1, "Starting bitbake-worker") 862 logger.debug(1, "Starting bitbake-worker")
@@ -912,11 +913,12 @@ class RunQueue:
912 continue 913 continue
913 workerpipe.close() 914 workerpipe.close()
914 915
915 def sigchild_exception(self, signum, stackframe): 916 def sigchild_exception(self, *args, **kwargs):
916 pid = True 917 for w in [self.worker, self.fakeworker]:
917 while pid: 918 if not w:
919 continue
918 try: 920 try:
919 pid, status = os.waitpid(-1, os.WNOHANG) 921 pid, status = os.waitpid(w.pid, os.WNOHANG)
920 if pid != 0 and not self.teardown: 922 if pid != 0 and not self.teardown:
921 if self.worker and pid == self.worker.pid: 923 if self.worker and pid == self.worker.pid:
922 name = "Worker" 924 name = "Worker"
@@ -928,11 +930,14 @@ class RunQueue:
928 self.finish_runqueue(True) 930 self.finish_runqueue(True)
929 except OSError: 931 except OSError:
930 pid = False 932 pid = False
933 if callable(self.oldsigchld):
934 self.oldsigchld(*args, **kwargs)
931 935
932 def start_worker(self): 936 def start_worker(self):
933 if self.worker: 937 if self.worker:
934 self.teardown_workers() 938 self.teardown_workers()
935 self.teardown = False 939 self.teardown = False
940 self.oldsigchld = signal.getsignal(signal.SIGCHLD)
936 signal.signal(signal.SIGCHLD, self.sigchild_exception) 941 signal.signal(signal.SIGCHLD, self.sigchild_exception)
937 self.worker, self.workerpipe = self._start_worker() 942 self.worker, self.workerpipe = self._start_worker()
938 943
@@ -942,7 +947,7 @@ class RunQueue:
942 947
943 def teardown_workers(self): 948 def teardown_workers(self):
944 self.teardown = True 949 self.teardown = True
945 signal.signal(signal.SIGCHLD, signal.SIG_DFL) 950 signal.signal(signal.SIGCHLD, self.oldsigchld)
946 self._teardown_worker(self.worker, self.workerpipe) 951 self._teardown_worker(self.worker, self.workerpipe)
947 self.worker = None 952 self.worker = None
948 self.workerpipe = None 953 self.workerpipe = None