Skip to content
Merged
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
15 changes: 11 additions & 4 deletions src/azure-cli/azure/cli/command_modules/container/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,10 +1003,16 @@ def _on_ws_open_windows(ws):

def _start_exec_pipe_linux(web_socket_uri, password):
stdin_fd = sys.stdin.fileno()
old_tty = termios.tcgetattr(stdin_fd)
try:
old_tty = termios.tcgetattr(stdin_fd)
has_tty = True
except termios.error:
old_tty = None
has_tty = False
old_winch_handler = signal.getsignal(signal.SIGWINCH)
tty.setraw(stdin_fd)
tty.setcbreak(stdin_fd)
if has_tty:
tty.setraw(stdin_fd)
tty.setcbreak(stdin_fd)
buff = bytearray()
lock = threading.Lock()

Expand All @@ -1018,7 +1024,8 @@ def _on_ws_open_linux(ws):
flushKeyboard.start()
ws = websocket.WebSocketApp(web_socket_uri, on_open=_on_ws_open_linux, on_message=_on_ws_msg)
ws.run_forever()
termios.tcsetattr(stdin_fd, termios.TCSADRAIN, old_tty)
if has_tty:
termios.tcsetattr(stdin_fd, termios.TCSADRAIN, old_tty)
signal.signal(signal.SIGWINCH, old_winch_handler)


Expand Down
Loading