quit when shell exits

This commit is contained in:
~d6 2023-01-21 15:58:02 -05:00
parent 3bfd045159
commit c5a850b9e1
1 changed files with 12 additions and 5 deletions

17
term.py
View File

@ -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()