Update terminalManagement

This commit is contained in:
chrys87 2017-08-24 11:29:19 +02:00 committed by GitHub
parent 9d98976fdb
commit d29e0069ba

View File

@ -53,10 +53,7 @@ def HandleTerminal():
tty.setraw(0) tty.setraw(0)
terminal, p_pid, p_out = open_terminal() terminal, p_pid, p_out = open_terminal()
std_out = os.fdopen(sys.stdout.fileno(), "w+b", 0) std_out = os.fdopen(sys.stdout.fileno(), "w+b", 0)
#termios.tcdrain(p_pid)
#termios.tcdrain(0)
while running: while running:
#time.sleep(0.04)
r, w, x = select.select([sys.stdin, p_out],[],[]) r, w, x = select.select([sys.stdin, p_out],[],[])
if r == []: if r == []:
continue continue
@ -65,9 +62,6 @@ def HandleTerminal():
print('pre p_out') print('pre p_out')
try: try:
msgBytes = read_all(p_out.fileno()) msgBytes = read_all(p_out.fileno())
#msgBytes = p_out.read(65536)
#msgBytes = os.read(p_out.fileno(), 4)
#p_out.read(4096)
except (EOFError, OSError): except (EOFError, OSError):
running = False running = False
break break
@ -82,13 +76,9 @@ def HandleTerminal():
print('pre stdin') print('pre stdin')
try: try:
msgBytes = read_all(sys.stdin.fileno()) msgBytes = read_all(sys.stdin.fileno())
#msgBytes = p_out.read(65536)
#msgBytes = os.read(p_out.fileno(), 4)
#p_out.read(4096)
except (EOFError, OSError): except (EOFError, OSError):
running = False running = False
break break
#msgBytes = os.read(sys.stdin.fileno(), 1)
terminal.feed(msgBytes) terminal.feed(msgBytes)
os.write(p_out.fileno(), msgBytes) os.write(p_out.fileno(), msgBytes)
if debug: if debug:
@ -97,7 +87,6 @@ def HandleTerminal():
print(e) print(e)
running = False running = False
finally: finally:
#termios.tcsetattr(0, termios.TCSADRAIN, attr)
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)