This is an automated email from the ASF dual-hosted git repository. juergbi pushed a commit to branch juerg/preexec in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 9364c439be93026017e81563a43387fe6c52d4aa Author: Seppo Yli-Olli <[email protected]> AuthorDate: Fri Sep 16 20:39:05 2022 +0300 Use subprocess umask support This requires Python 3.9 or newer --- src/buildstream/utils.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/buildstream/utils.py b/src/buildstream/utils.py index 9d058a28e..572ba26f4 100644 --- a/src/buildstream/utils.py +++ b/src/buildstream/utils.py @@ -1260,14 +1260,7 @@ def _call(*popenargs, terminate=False, **kwargs): process = None - old_preexec_fn = kwargs.get("preexec_fn") - if "preexec_fn" in kwargs: - del kwargs["preexec_fn"] - - def preexec_fn(): - os.umask(stat.S_IWGRP | stat.S_IWOTH) - if old_preexec_fn is not None: - old_preexec_fn() + kwargs["umask"] = stat.S_IWGRP | stat.S_IWOTH # Handle termination, suspend and resume def kill_proc(): @@ -1313,7 +1306,7 @@ def _call(*popenargs, terminate=False, **kwargs): os.killpg(group_id, signal.SIGCONT) with _signals.suspendable(suspend_proc, resume_proc), _signals.terminator(kill_proc), subprocess.Popen( - *popenargs, preexec_fn=preexec_fn, universal_newlines=True, **kwargs + *popenargs, universal_newlines=True, **kwargs ) as process: # Here, we don't use `process.communicate()` directly without a timeout # This is because, if we were to do that, and the process would never
