summaryrefslogtreecommitdiffstats
path: root/bitbake/bin/bitbake-worker
diff options
context:
space:
mode:
authorIvan Efimov <i.efimov@inango-systems.com>2019-11-05 19:07:03 +0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-11-07 15:12:29 +0000
commit4917e7b1a40559b19d2580f4180ad6ccbfc7fd04 (patch)
tree25448a347f3dc76676d82fd78da1578d5319020b /bitbake/bin/bitbake-worker
parentca01520a0b2378e879c70fc0e1b85608f1c3dc2b (diff)
downloadpoky-4917e7b1a40559b19d2580f4180ad6ccbfc7fd04.tar.gz
bitbake: 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. (Bitbake rev: b97b1ef0b1b00848a4a44b34eca123ccf33188f4) Signed-off-by: Ivan Efimov <i.efimov@inango-systems.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/bin/bitbake-worker')
-rwxr-xr-xbitbake/bin/bitbake-worker8
1 files changed, 5 insertions, 3 deletions
diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker
index 6776cadda3..1e641e81c2 100755
--- a/bitbake/bin/bitbake-worker
+++ b/bitbake/bin/bitbake-worker
@@ -195,9 +195,6 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, taskha
195 global worker_pipe_lock 195 global worker_pipe_lock
196 pipein.close() 196 pipein.close()
197 197
198 signal.signal(signal.SIGTERM, sigterm_handler)
199 # Let SIGHUP exit as SIGTERM
200 signal.signal(signal.SIGHUP, sigterm_handler)
201 bb.utils.signal_on_parent_exit("SIGTERM") 198 bb.utils.signal_on_parent_exit("SIGTERM")
202 199
203 # Save out the PID so that the event can include it the 200 # Save out the PID so that the event can include it the
@@ -212,6 +209,11 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, taskha
212 # This ensures signals sent to the controlling terminal like Ctrl+C 209 # This ensures signals sent to the controlling terminal like Ctrl+C
213 # don't stop the child processes. 210 # don't stop the child processes.
214 os.setsid() 211 os.setsid()
212
213 signal.signal(signal.SIGTERM, sigterm_handler)
214 # Let SIGHUP exit as SIGTERM
215 signal.signal(signal.SIGHUP, sigterm_handler)
216
215 # No stdin 217 # No stdin
216 newsi = os.open(os.devnull, os.O_RDWR) 218 newsi = os.open(os.devnull, os.O_RDWR)
217 os.dup2(newsi, sys.stdin.fileno()) 219 os.dup2(newsi, sys.stdin.fileno())