Skip to content

Commit b8656e2

Browse files
MatthijsBurghar13pit
authored andcommitted
Don't write to stdin of closed process
1 parent 3a61d2a commit b8656e2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/tue_get/installer_impl.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,12 @@ def _set_target(self, target: str):
155155
self._current_target_dir = parent_target_dir
156156

157157
def _out_handler(self, sub: BackgroundPopen, line: str) -> None:
158-
def _write_stdin(msg) -> None:
158+
def _write_stdin(msg: str) -> None:
159+
if sub.returncode is not None:
160+
self.tue_install_error(
161+
f"Cannot write to stdin of process {sub.pid} as it has already terminated {line=}"
162+
)
163+
return
159164
sub.stdin.write(f"{msg}\n")
160165
sub.stdin.flush()
161166

0 commit comments

Comments
 (0)