Skip to content

Commit a9b05b5

Browse files
authored
Raise EOFError during process.recv when stdout closes on Windows (#2524)
* 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. * Update CHANGELOG
1 parent fac8f1e commit a9b05b5

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,11 @@ The table below shows which release corresponds to each branch, and what date th
7676

7777
- [#2507][2507] Add `+LINUX` and `+WINDOWS` doctest options and start proper testing on Windows
7878
- [#2522][2522] Support starting a kitty debugging window with the 'kitten' command
79+
- [#2524][2524] Raise EOFError during `process.recv` when stdout closes on Windows
7980

8081
[2507]: https://github.com/Gallopsled/pwntools/pull/2507
8182
[2522]: https://github.com/Gallopsled/pwntools/pull/2522
83+
[2524]: https://github.com/Gallopsled/pwntools/pull/2524
8284

8385
## 4.15.0 (`beta`)
8486
- [#2508][2508] Ignore a warning when compiling with asm on nix

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)