summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Efimov <i.efimov@inango-systems.com>2019-11-05 14:07:03 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-11-07 19:47:12 (GMT)
commitcbb677e9a09d5dad34404a851f7c23aeb5122465 (patch)
tree243efbd70348ecddc8efc87e61c9ec2eba9406cf
parente58082e22d265246b145d2d7ffb1e3adcb2cc177 (diff)
downloadpoky-sumo.tar.gz
bitbake: bitbake-worker child process create group before registering SIGTERM handlersumo
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: 945719d852da6c787bc9115bd0aa90c429f5de07) Signed-off-by: Ivan Efimov <i.efimov@inango-systems.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-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 e925054..0e66905 100755
--- a/bitbake/bin/bitbake-worker
+++ b/bitbake/bin/bitbake-worker
@@ -192,9 +192,6 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, append
192 global worker_pipe_lock 192 global worker_pipe_lock
193 pipein.close() 193 pipein.close()
194 194
195 signal.signal(signal.SIGTERM, sigterm_handler)
196 # Let SIGHUP exit as SIGTERM
197 signal.signal(signal.SIGHUP, sigterm_handler)
198 bb.utils.signal_on_parent_exit("SIGTERM") 195 bb.utils.signal_on_parent_exit("SIGTERM")
199 196
200 # Save out the PID so that the event can include it the 197 # 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
209 # This ensures signals sent to the controlling terminal like Ctrl+C 206 # This ensures signals sent to the controlling terminal like Ctrl+C
210 # don't stop the child processes. 207 # don't stop the child processes.
211 os.setsid() 208 os.setsid()
209
210 signal.signal(signal.SIGTERM, sigterm_handler)
211 # Let SIGHUP exit as SIGTERM
212 signal.signal(signal.SIGHUP, sigterm_handler)
213
212 # No stdin 214 # No stdin
213 newsi = os.open(os.devnull, os.O_RDWR) 215 newsi = os.open(os.devnull, os.O_RDWR)
214 os.dup2(newsi, sys.stdin.fileno()) 216 os.dup2(newsi, sys.stdin.fileno())