Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions invoke/terminals.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ def bytes_to_read(input_: IO) -> int:
# it's not a tty but has a fileno, or vice versa; neither is typically
# going to work re: ioctl().
if not WINDOWS and isatty(input_) and has_fileno(input_):
fionread = fcntl.ioctl(input_, termios.FIONREAD, b" ")
return int(struct.unpack("h", fionread)[0])
arg = bytes(bytearray(struct.calcsize("i")))
fionread = fcntl.ioctl(input_, termios.FIONREAD, arg)
return int(struct.unpack("i", fionread)[0])
return 1
2 changes: 1 addition & 1 deletion tests/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ def fake_ioctl(fd, cmd, buf):
# This works since each mocked attr will still be its own mock
# object with a distinct 'is' identity.
if cmd is termios.FIONREAD:
return struct.pack("h", len(stdin_data))
return struct.pack("i", len(stdin_data))

ioctl.side_effect = fake_ioctl
# Set up our runner as one w/ mocked stdin writing (simplest way to
Expand Down