Skip to content

Commit

Permalink
Merge pull request #1754 from nanonyme/pre-exec
Browse files Browse the repository at this point in the history
Use subprocess umask support
  • Loading branch information
juergbi authored Jan 11, 2025
2 parents 2b60165 + c578437 commit 504e442
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/buildstream/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
#
# Authors:
# Tristan Van Berkom <[email protected]>

# 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
=========
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 504e442

Please sign in to comment.