Update terminalManagement

This commit is contained in:
chrys87 2017-08-24 15:51:16 +02:00 committed by GitHub
parent 5bd250e67f
commit bd113bb640

View File

@ -34,7 +34,6 @@ class Terminal:
def open_terminal(command="bash", columns=80, lines=24): def open_terminal(command="bash", columns=80, lines=24):
p_pid, master_fd = pty.fork() p_pid, master_fd = pty.fork()
print('PID',p_pid)
if p_pid == 0: # Child. if p_pid == 0: # Child.
argv = shlex.split(command) argv = shlex.split(command)
env = os.environ.copy() env = os.environ.copy()
@ -47,7 +46,6 @@ def open_terminal(command="bash", columns=80, lines=24):
def HandleTerminal(): def HandleTerminal():
debug = False debug = False
running = True running = True
#attr = termios.tcgetattr(sys.stdin.fileno())
try: try:
old_attr = termios.tcgetattr(sys.stdin) old_attr = termios.tcgetattr(sys.stdin)
tty.setraw(0) tty.setraw(0)
@ -65,10 +63,8 @@ def HandleTerminal():
except (EOFError, OSError): except (EOFError, OSError):
running = False running = False
break break
#sys.exit(0) terminal.feed(msgBytes)
os.write(sys.stdout.fileno(), msgBytes) os.write(sys.stdout.fileno(), msgBytes)
sys.stdout.flush()
#print(terminal.screen.display)
if debug: if debug:
print('after p_out') print('after p_out')
if sys.stdin in r: if sys.stdin in r:
@ -90,6 +86,7 @@ def HandleTerminal():
os.kill(p_pid, signal.SIGTERM) os.kill(p_pid, signal.SIGTERM)
p_out.close() p_out.close()
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_attr) termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_attr)
sys.exit(0)
def get_terminal_size(fd): def get_terminal_size(fd):
s = struct.pack('HHHH', 0, 0, 0, 0) s = struct.pack('HHHH', 0, 0, 0, 0)