mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-05 10:13:05 +00:00
revert back is_terminal
This commit is contained in:
parent
f66109c861
commit
3673c98c9a
1 changed files with 6 additions and 12 deletions
|
@ -23,9 +23,7 @@ def run_with_pty(command):
|
|||
master, slave = pty.openpty()
|
||||
|
||||
# Check if stdin is actually a terminal
|
||||
is_terminal = sys.stdin.isatty()
|
||||
if is_terminal:
|
||||
old_settings = termios.tcgetattr(sys.stdin)
|
||||
old_settings = termios.tcgetattr(sys.stdin)
|
||||
|
||||
original_sigint = signal.getsignal(signal.SIGINT)
|
||||
|
||||
|
@ -41,13 +39,10 @@ def run_with_pty(command):
|
|||
signal.signal(signal.SIGINT, sigint_handler)
|
||||
|
||||
# Only modify terminal settings if we're actually in a terminal
|
||||
if is_terminal:
|
||||
new_settings = termios.tcgetattr(sys.stdin)
|
||||
new_settings[3] = new_settings[3] & ~termios.ECHO # Disable echo
|
||||
new_settings[3] = (
|
||||
new_settings[3] & ~termios.ICANON
|
||||
) # Disable canonical mode
|
||||
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, new_settings)
|
||||
new_settings = termios.tcgetattr(sys.stdin)
|
||||
new_settings[3] = new_settings[3] & ~termios.ECHO # Disable echo
|
||||
new_settings[3] = new_settings[3] & ~termios.ICANON # Disable canonical mode
|
||||
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, new_settings)
|
||||
|
||||
process = subprocess.Popen(
|
||||
command,
|
||||
|
@ -94,8 +89,7 @@ def run_with_pty(command):
|
|||
raise
|
||||
finally:
|
||||
# Clean up
|
||||
if is_terminal:
|
||||
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_settings)
|
||||
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_settings)
|
||||
signal.signal(signal.SIGINT, original_sigint)
|
||||
|
||||
os.close(master)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue