Skip to content

Commit db87d46

Browse files
committed
Use subprocess umask support
This requires Python 3.9 or newer
1 parent f0923e2 commit db87d46

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

src/buildstream/utils.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@
1313
#
1414
# Authors:
1515
# Tristan Van Berkom <tristan.vanberkom@codethink.co.uk>
16-
17-
# Disable this for the file, because pylint is not picking it up
18-
# when specifying it on the specific line.
19-
#
20-
# pylint: disable=subprocess-popen-preexec-fn
21-
#
2216
"""
2317
Utilities
2418
=========
@@ -1260,14 +1254,7 @@ def _call(*popenargs, terminate=False, **kwargs):
12601254

12611255
process = None
12621256

1263-
old_preexec_fn = kwargs.get("preexec_fn")
1264-
if "preexec_fn" in kwargs:
1265-
del kwargs["preexec_fn"]
1266-
1267-
def preexec_fn():
1268-
os.umask(stat.S_IWGRP | stat.S_IWOTH)
1269-
if old_preexec_fn is not None:
1270-
old_preexec_fn()
1257+
kwargs["umask"] = stat.S_IWGRP | stat.S_IWOTH
12711258

12721259
# Handle termination, suspend and resume
12731260
def kill_proc():
@@ -1313,7 +1300,7 @@ def resume_proc():
13131300
os.killpg(group_id, signal.SIGCONT)
13141301

13151302
with _signals.suspendable(suspend_proc, resume_proc), _signals.terminator(kill_proc), subprocess.Popen(
1316-
*popenargs, preexec_fn=preexec_fn, universal_newlines=True, **kwargs
1303+
*popenargs, universal_newlines=True, **kwargs
13171304
) as process:
13181305
# Here, we don't use `process.communicate()` directly without a timeout
13191306
# This is because, if we were to do that, and the process would never

0 commit comments

Comments
 (0)