mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-06 02:32:40 +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()
|
master, slave = pty.openpty()
|
||||||
|
|
||||||
# Check if stdin is actually a terminal
|
# Check if stdin is actually a terminal
|
||||||
is_terminal = sys.stdin.isatty()
|
old_settings = termios.tcgetattr(sys.stdin)
|
||||||
if is_terminal:
|
|
||||||
old_settings = termios.tcgetattr(sys.stdin)
|
|
||||||
|
|
||||||
original_sigint = signal.getsignal(signal.SIGINT)
|
original_sigint = signal.getsignal(signal.SIGINT)
|
||||||
|
|
||||||
|
@ -41,13 +39,10 @@ def run_with_pty(command):
|
||||||
signal.signal(signal.SIGINT, sigint_handler)
|
signal.signal(signal.SIGINT, sigint_handler)
|
||||||
|
|
||||||
# Only modify terminal settings if we're actually in a terminal
|
# Only modify terminal settings if we're actually in a terminal
|
||||||
if is_terminal:
|
new_settings = termios.tcgetattr(sys.stdin)
|
||||||
new_settings = termios.tcgetattr(sys.stdin)
|
new_settings[3] = new_settings[3] & ~termios.ECHO # Disable echo
|
||||||
new_settings[3] = new_settings[3] & ~termios.ECHO # Disable echo
|
new_settings[3] = new_settings[3] & ~termios.ICANON # Disable canonical mode
|
||||||
new_settings[3] = (
|
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, new_settings)
|
||||||
new_settings[3] & ~termios.ICANON
|
|
||||||
) # Disable canonical mode
|
|
||||||
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, new_settings)
|
|
||||||
|
|
||||||
process = subprocess.Popen(
|
process = subprocess.Popen(
|
||||||
command,
|
command,
|
||||||
|
@ -94,8 +89,7 @@ def run_with_pty(command):
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
# Clean up
|
# 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)
|
signal.signal(signal.SIGINT, original_sigint)
|
||||||
|
|
||||||
os.close(master)
|
os.close(master)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue