Meta: Only kill child process in run_command() if it is bound
Scoping here was backwards, causing 'process' to be possibly used while unbound.
This commit is contained in:
parent
675e209f5e
commit
d89e9bb44d
1 changed files with 7 additions and 7 deletions
|
|
@ -21,9 +21,9 @@ def run_command(
|
|||
stdin = subprocess.PIPE if type(input) is str else None
|
||||
stdout = subprocess.PIPE if return_output else None
|
||||
|
||||
try:
|
||||
# FIXME: For Windows, set the working directory so DLLs are found.
|
||||
with subprocess.Popen(command, stdin=stdin, stdout=stdout, text=True, cwd=cwd) as process:
|
||||
# FIXME: For Windows, set the working directory so DLLs are found.
|
||||
with subprocess.Popen(command, stdin=stdin, stdout=stdout, text=True, cwd=cwd) as process:
|
||||
try:
|
||||
(output, _) = process.communicate(input=input)
|
||||
|
||||
if process.returncode != 0:
|
||||
|
|
@ -31,11 +31,11 @@ def run_command(
|
|||
sys.exit(process.returncode)
|
||||
return None
|
||||
|
||||
except KeyboardInterrupt:
|
||||
process.send_signal(signal.SIGINT)
|
||||
process.wait()
|
||||
except KeyboardInterrupt:
|
||||
process.send_signal(signal.SIGINT)
|
||||
process.wait()
|
||||
|
||||
sys.exit(process.returncode)
|
||||
sys.exit(process.returncode)
|
||||
|
||||
if return_output:
|
||||
return output.strip()
|
||||
|
|
|
|||
Loading…
Reference in a new issue