diff --git a/term.py b/term.py index f3958f7..dcc63ec 100755 --- a/term.py +++ b/term.py @@ -1,15 +1,15 @@ #!/usr/bin/python +# +# ./term.py term.rom /bin/bash from select import select from subprocess import Popen, PIPE, STDOUT import sys -# TODO: byte-by-byte I/O is painful. figure out better buffering -# that doesn't break everything - -# currently line-buffered +# currently unbuffered +# +# TODO: figure out a more reasonable buffering strategy def run(args): - #return Popen(args, stdin=PIPE, stdout=PIPE, stderr=STDOUT, bufsize=1, universal_newlines=True) return Popen(args, stdin=PIPE, stdout=PIPE, stderr=STDOUT, bufsize=0) def main(): @@ -19,6 +19,8 @@ def main(): print('') print('execute the given uxn terminal program (ROM)') print('and start a shell process (SHELL).') + print('') + print('example: %s term.rom /bin/bash' % sys.argv[0]) sys.exit(1) rom = args[0] shell = args[1] @@ -41,6 +43,11 @@ def main(): term.stdin.flush() else: raise Exception('unexpected fileno: %d (expected %d or %d)' % (n, term_out, shell_out)) + + if shell.poll() is None: + shell.kill() + if term.poll() is None: + term.kill() if __name__ == "__main__": main()