diff options
author | Ivan Efimov <i.efimov@inango-systems.com> | 2019-11-05 19:07:03 +0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-11-06 13:58:55 +0000 |
commit | b97b1ef0b1b00848a4a44b34eca123ccf33188f4 (patch) | |
tree | a8d2a87b052ab257374f5d27e2ecce61ffbb7769 /bin | |
parent | 0c4515603ad08775e3b0404cba5374367e49f236 (diff) | |
download | bitbake-b97b1ef0b1b00848a4a44b34eca123ccf33188f4.tar.gz |
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@inango-systems.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/bitbake-worker | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/bin/bitbake-worker b/bin/bitbake-worker index 6776cadda..1e641e81c 100755 --- a/bin/bitbake-worker +++ b/bin/bitbake-worker @@ -195,9 +195,6 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, taskha 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 @@ -212,6 +209,11 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, taskha # 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()) |