-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1754 from nanonyme/pre-exec
Use subprocess umask support
- Loading branch information
Showing
1 changed file
with
2 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
========= | ||
|
@@ -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 | ||
|