Skip to content
This repository has been archived by the owner on Jan 14, 2024. It is now read-only.

Commit

Permalink
#57: Do not copy terminal size if the console is non-interactive to a…
Browse files Browse the repository at this point in the history
…void exception
  • Loading branch information
blackandred committed Nov 11, 2020
1 parent c8e4eac commit 4fabe00
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/rkd/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,17 @@ def push_output(process, primary_fd, out_buffer: TextBuffer, process_state: Proc
# terminal window size updating
terminal_update_time = 3 # 3 seconds
last_terminal_update = time()
should_update_terminal_size = True

if is_interactive_session:
try:
copy_terminal_size(sys.stdout, primary_fd)
except OSError as e:
if e.errno == 25:
should_update_terminal_size = False
else:
raise

if is_interactive_session:
to_select = [sys.stdin] + to_select

while process.poll() is None:
Expand All @@ -118,7 +126,7 @@ def push_output(process, primary_fd, out_buffer: TextBuffer, process_state: Proc
o = os.read(primary_fd, 10240)

# terminal window size updating
if is_interactive_session and time() - last_terminal_update >= terminal_update_time:
if should_update_terminal_size and time() - last_terminal_update >= terminal_update_time:
copy_terminal_size(sys.stdout, primary_fd)

# propagate to stdout
Expand Down

0 comments on commit 4fabe00

Please sign in to comment.