From c578437c8882fd259a01adee666b2ffbd755cac7 Mon Sep 17 00:00:00 2001 From: Seppo Yli-Olli Date: Fri, 16 Sep 2022 20:39:05 +0300 Subject: [PATCH] Use subprocess umask support This requires Python 3.9 or newer --- src/buildstream/utils.py | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/buildstream/utils.py b/src/buildstream/utils.py index 9d058a28e..229230237 100644 --- a/src/buildstream/utils.py +++ b/src/buildstream/utils.py @@ -13,12 +13,6 @@ # # Authors: # Tristan Van Berkom - -# Disable this for the file, because pylint is not picking it up -# when specifying it on the specific line. -# -# pylint: disable=subprocess-popen-preexec-fn -# """ Utilities ========= @@ -1260,14 +1254,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.setdefault("umask", stat.S_IWGRP | stat.S_IWOTH) # Handle termination, suspend and resume def kill_proc(): @@ -1313,7 +1300,7 @@ def resume_proc(): 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