Skip to content

Commit 83b3e42

Browse files
committed
Windows: Raise EOFError during process.recv when stdout closes
If the receiving thread terminates while we're waiting for data to arrive we'd be waiting endlessly. Raise EOFError when .recv()ing on a process with stdout closed and no more data queued up from the receiver thread.
1 parent 29fb02f commit 83b3e42

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pwnlib/tubes/process.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -767,9 +767,13 @@ def can_recv_raw(self, timeout):
767767

768768
if IS_WINDOWS:
769769
with self.countdown(timeout=timeout):
770-
while self.timeout and self._read_queue.empty():
770+
while self.timeout and self._read_queue.empty() and self._read_thread.is_alive():
771771
time.sleep(0.01)
772-
return not self._read_queue.empty()
772+
if not self._read_queue.empty():
773+
return True
774+
if not self._read_thread.is_alive():
775+
raise EOFError
776+
return False
773777

774778
try:
775779
if timeout is None:

0 commit comments

Comments
 (0)