[oe-commits] [bitbake] branch 1.40 updated: bitbake-worker child process create group before registering SIGTERM handler

git at git.openembedded.org git at git.openembedded.org
Thu Nov 7 19:48:01 UTC 2019


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch 1.40
in repository bitbake.

The following commit(s) were added to refs/heads/1.40 by this push:
     new b51877c  bitbake-worker child process create group before registering SIGTERM handler
b51877c is described below

commit b51877cbb8a7c713aa2bcec8354ec66e2f3dad51
Author: Ivan Efimov <i.efimov at inango-systems.com>
AuthorDate: Tue Nov 5 19:07:03 2019 +0500

    bitbake-worker child process create group before registering SIGTERM handler
    
    The bitbake-worker child on the SIGTERM signal handling send the SIGTERM to all
    processes in it's process group. In cases when the bitbake-worker child got
    SIGTERM after registering own SIGTERM handler and before the os.setsid() call
    it can send SIGTERM to unwanted processes.
    
    In the worst case during SIGTERM processing the bitbake-worker child can be in
    the group of the process that started BitBake itself. As a result it can kill
    processes that not related to BitBake at all.
    
    Signed-off-by: Ivan Efimov <i.efimov at inango-systems.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 bin/bitbake-worker | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/bin/bitbake-worker b/bin/bitbake-worker
index e925054..0e66905 100755
--- a/bin/bitbake-worker
+++ b/bin/bitbake-worker
@@ -192,9 +192,6 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, append
             global worker_pipe_lock
             pipein.close()
 
-            signal.signal(signal.SIGTERM, sigterm_handler)
-            # Let SIGHUP exit as SIGTERM
-            signal.signal(signal.SIGHUP, sigterm_handler)
             bb.utils.signal_on_parent_exit("SIGTERM")
 
             # Save out the PID so that the event can include it the
@@ -209,6 +206,11 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, append
             # This ensures signals sent to the controlling terminal like Ctrl+C
             # don't stop the child processes.
             os.setsid()
+
+            signal.signal(signal.SIGTERM, sigterm_handler)
+            # Let SIGHUP exit as SIGTERM
+            signal.signal(signal.SIGHUP, sigterm_handler)
+
             # No stdin
             newsi = os.open(os.devnull, os.O_RDWR)
             os.dup2(newsi, sys.stdin.fileno())

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list