@@ -137,36 +137,36 @@ def _set_terminal_raw_mode():
137137 kernel32 .SetConsoleMode (stdin_handle , new_mode )
138138
139139 return stdin_handle , old_mode .value
140- else :
141- # Unix/Linux raw mode implementation
142- # Reference: https://github.com/moby/term/blob/main/termios_unix.go
143- fd = sys .stdin .fileno ()
144- old_settings = termios .tcgetattr (fd )
145- new_settings = list (old_settings )
146140
147- # Input modes - clear IGNBRK, BRKINT, PARMRK, ISTRIP, INLCR, IGNCR, ICRNL, IXON
148- new_settings [0 ] &= ~ (termios .IGNBRK | termios .BRKINT | termios .PARMRK |
149- termios .ISTRIP | termios .INLCR | termios .IGNCR |
150- termios .ICRNL | termios .IXON )
141+ # Unix/Linux raw mode implementation
142+ # Reference: https://github.com/moby/term/blob/main/termios_unix.go
143+ fd = sys .stdin .fileno ()
144+ old_settings = termios .tcgetattr (fd )
145+ new_settings = list (old_settings )
151146
152- # Output modes - clear OPOST
153- new_settings [1 ] &= ~ termios .OPOST
147+ # Input modes - clear IGNBRK, BRKINT, PARMRK, ISTRIP, INLCR, IGNCR, ICRNL, IXON
148+ new_settings [0 ] &= ~ (termios .IGNBRK | termios .BRKINT | termios .PARMRK |
149+ termios .ISTRIP | termios .INLCR | termios .IGNCR |
150+ termios .ICRNL | termios .IXON )
154151
155- # Local modes - clear ECHO, ECHONL, ICANON, ISIG, IEXTEN
156- new_settings [3 ] &= ~ (termios .ECHO | termios .ECHONL | termios .ICANON |
157- termios .ISIG | termios .IEXTEN )
152+ # Output modes - clear OPOST
153+ new_settings [1 ] &= ~ termios .OPOST
158154
159- # Control modes - clear CSIZE, PARENB; set CS8
160- new_settings [2 ] &= ~ (termios .CSIZE | termios .PARENB )
161- new_settings [ 2 ] |= termios .CS8
155+ # Local modes - clear ECHO, ECHONL, ICANON, ISIG, IEXTEN
156+ new_settings [3 ] &= ~ (termios .ECHO | termios .ECHONL | termios . ICANON |
157+ termios . ISIG | termios .IEXTEN )
162158
163- # Control characters - set VMIN = 1, VTIME = 0
164- new_settings [6 ][ termios .VMIN ] = 1
165- new_settings [6 ][ termios . VTIME ] = 0
159+ # Control modes - clear CSIZE, PARENB; set CS8
160+ new_settings [2 ] &= ~ ( termios .CSIZE | termios . PARENB )
161+ new_settings [2 ] |= termios . CS8
166162
167- termios .tcsetattr (fd , termios .TCSADRAIN , new_settings )
163+ # Control characters - set VMIN = 1, VTIME = 0
164+ new_settings [6 ][termios .VMIN ] = 1
165+ new_settings [6 ][termios .VTIME ] = 0
168166
169- return fd , old_settings
167+ termios .tcsetattr (fd , termios .TCSADRAIN , new_settings )
168+
169+ return fd , old_settings
170170
171171
172172def _restore_terminal_mode (fd_or_handle , old_settings , windows_console_state = None ):
@@ -265,7 +265,7 @@ def _heartbeat_worker(exec_stream, stop_event):
265265 stop_event .wait (min (1.0 , HEARTBEAT_INTERVAL / 5 ))
266266
267267
268- def exec_command_in_pod (pod_name : str , command : List [str ], # pylint: disable=too-many-branches
268+ def exec_command_in_pod (pod_name : str , command : List [str ], # pylint: disable=too-many-branches,too-many-locals
269269 namespace : str = AGENT_NAMESPACE ,
270270 kubeconfig_path : Optional [str ] = None ,
271271 interactive : bool = True ,
@@ -297,7 +297,7 @@ def exec_command_in_pod(pod_name: str, command: List[str], # pylint: disable=to
297297
298298 def cleanup ():
299299 """Cleanup function to ensure proper resource cleanup."""
300- nonlocal terminal_state , original_sigwinch , fd , fl , resp , cleanup_done , windows_console_state
300+ nonlocal cleanup_done
301301
302302 # Prevent duplicate cleanup
303303 if cleanup_done :
0 commit comments