Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] bitbake-worker: Improve sigterm handler
@ 2014-08-21 20:46 Richard Purdie
  0 siblings, 0 replies; only message in thread
From: Richard Purdie @ 2014-08-21 20:46 UTC (permalink / raw)
  To: openembedded-core

When processes terminate, we really want all of the child processes to
terminate too. This was not happening for worker processes which spawned their
own multiprocessing pools, leading to build hangs. This change ensures any
sigterm gets passed to the whole process group. In local tests, this resolved
some hanging process workloads I could generate. It does rely on signals
being delivered in a timely fashion and there is a multiprocessing bug we have
to work around there.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker
index 05e0cf6..d1ff5b3 100755
--- a/bitbake/bin/bitbake-worker
+++ b/bitbake/bin/bitbake-worker
@@ -81,6 +81,11 @@ def workerlog_write(msg):
         lf.write(msg)
         lf.flush()
 
+def sigterm_handler(signum, frame):
+    signal.signal(signal.SIGTERM, signal.SIG_DFL)
+    os.killpg(0, signal.SIGTERM)
+    sys.exit()
+
 def fork_off_task(cfg, data, workerdata, fn, task, taskname, appends, taskdepdata, quieterrors=False):
     # We need to setup the environment BEFORE the fork, since
     # a fork() or exec*() activates PSEUDO...
@@ -132,7 +137,7 @@ def fork_off_task(cfg, data, workerdata, fn, task, taskname, appends, taskdepdat
             global worker_pipe
             pipein.close()
 
-            signal.signal(signal.SIGTERM, signal.SIG_DFL)
+            signal.signal(signal.SIGTERM, sigterm_handler)
 
             # Save out the PID so that the event can include it the
             # events




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-08-21 20:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-21 20:46 [PATCH] bitbake-worker: Improve sigterm handler Richard Purdie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox