plugin: _execute_commands_in_subprocess: make sure pipes get closed
This commit is contained in:
@@ -338,15 +338,15 @@ class Plugins(DaemonThread):
|
|||||||
Executes the given commands in a subprocess and asserts that it was successful.
|
Executes the given commands in a subprocess and asserts that it was successful.
|
||||||
"""
|
"""
|
||||||
import subprocess
|
import subprocess
|
||||||
process = subprocess.Popen(
|
with subprocess.Popen(
|
||||||
commands,
|
commands,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
text=True
|
text=True,
|
||||||
)
|
) as process:
|
||||||
stdout, stderr = process.communicate()
|
stdout, stderr = process.communicate()
|
||||||
if process.returncode != 0:
|
if process.returncode != 0:
|
||||||
raise Exception(f'error executing command ({process.returncode}): {stderr}')
|
raise Exception(f'error executing command ({process.returncode}): {stderr}')
|
||||||
|
|
||||||
def _write_key_to_root_file_linux(self, key_hex: str) -> None:
|
def _write_key_to_root_file_linux(self, key_hex: str) -> None:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user