aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin Scholz <epirat07@gmail.com>2022-03-30 18:16:20 +0200
committerEli Schwartz <eschwartz93@gmail.com>2022-03-30 16:04:23 -0400
commit4b97c6065043e4268425bebec35f5c3722f73c2e (patch)
tree44ac70e36f5b296bc157d8c2a462b2d28b4a2bf8
parentbe63e77949657b2d7994d49bc04dd43a031d5aed (diff)
downloadmeson-4b97c6065043e4268425bebec35f5c3722f73c2e.zip
meson-4b97c6065043e4268425bebec35f5c3722f73c2e.tar.gz
meson-4b97c6065043e4268425bebec35f5c3722f73c2e.tar.bz2
compilers/gnu: use Popen_safe to prevent resource leaks
Fixes the following ResourceWarnings: ResourceWarning: subprocess 25556 is still running _warn("subprocess %s is still running" % self.pid, ResourceWarning: Enable tracemalloc to get the object allocation traceback mesonbuild/compilers/mixins/gnu.py:195: ResourceWarning: unclosed file <_io.BufferedReader name=4> return gnulike_default_include_dirs(tuple(self.exelist), self.language).copy() ResourceWarning: Enable tracemalloc to get the object allocation traceback
-rw-r--r--mesonbuild/compilers/mixins/gnu.py9
1 files changed, 1 insertions, 8 deletions
diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py
index b91788c..91e07e5 100644
--- a/mesonbuild/compilers/mixins/gnu.py
+++ b/mesonbuild/compilers/mixins/gnu.py
@@ -106,14 +106,7 @@ def gnulike_default_include_dirs(compiler: T.Tuple[str, ...], lang: str) -> 'Imm
env = os.environ.copy()
env["LC_ALL"] = 'C'
cmd = list(compiler) + [f'-x{lang}', '-E', '-v', '-']
- p = subprocess.Popen(
- cmd,
- stdin=subprocess.DEVNULL,
- stderr=subprocess.STDOUT,
- stdout=subprocess.PIPE,
- env=env
- )
- stdout = p.stdout.read().decode('utf-8', errors='replace')
+ _, stdout, _ = mesonlib.Popen_safe(cmd, stderr=subprocess.STDOUT, env=env)
parse_state = 0
paths = [] # type: T.List[str]
for line in stdout.split('\n'):