Have kitty @ use /dev/tty instead of stdout/stdin

Allows redirecting those streams, while still being able to send
messages. Downside is that if user runs it outside kitty there wont
be any useful error message.
This commit is contained in:
Kovid Goyal
2018-03-02 09:08:58 +05:30
parent aad4a1fd6a
commit bc21ec7551
2 changed files with 9 additions and 13 deletions
+2 -2
View File
@@ -279,14 +279,14 @@ def non_blocking_read(src=sys.stdin):
fcntl.fcntl(fd, fcntl.F_SETFL, oldfl)
def read_with_timeout(more_needed, timeout=10, src=sys.stdin):
def read_with_timeout(more_needed, timeout=10, src=sys.stdin.buffer):
import select
start_time = monotonic()
with non_blocking_read(src) as fd:
while timeout > monotonic() - start_time:
rd = select.select([fd], [], [], max(0, timeout - (monotonic() - start_time)))[0]
if rd:
data = sys.stdin.buffer.read()
data = src.read()
if not data:
break # eof
if not more_needed(data):