diff options
-rw-r--r-- | bitbake/lib/bb/runqueue.py | 15 |
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 |