Commit 31c446ba authored by Sebastien Bourdeauducq's avatar Sebastien Bourdeauducq
Browse files

build/tools: fix process/fd resource management when coloring

parent 8d68a3df
...@@ -48,10 +48,10 @@ def sub_rules(line, rules, max_matches=1): ...@@ -48,10 +48,10 @@ def sub_rules(line, rules, max_matches=1):
def subprocess_call_filtered(command, rules, *, max_matches=1, **kwargs): def subprocess_call_filtered(command, rules, *, max_matches=1, **kwargs):
proc = subprocess.Popen(command, stdout=subprocess.PIPE, with subprocess.Popen(command, stdout=subprocess.PIPE,
universal_newlines=True, bufsize=1, universal_newlines=True, bufsize=1,
**kwargs) **kwargs) as proc:
with proc: with open(proc.stdout.fileno(), errors="ignore", closefd=False) as stdout:
for line in open(proc.stdout.fileno(), errors="ignore"): for line in stdout:
print(sub_rules(line, rules, max_matches), end="") print(sub_rules(line, rules, max_matches), end="")
return proc.returncode return proc.wait()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment