1#!/usr/bin/env python3 2 3import os 4import sys 5import subprocess 6 7status = 1 8 9with subprocess.Popen(sys.argv[1:], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) as proc: 10 while True: 11 status = proc.poll() 12 if status: 13 break; 14 c = proc.stdout.read(1) 15 if c == b'\xe9': 16 c = proc.stdout.readline().decode('utf-8') 17 words = c.split() 18 if len(words) > 0: 19 if words[0] == 'exit': 20 proc.send_signal(1) 21 status = int(words[1]) 22 break 23 sys.stdout.write(c.decode('utf-8')) 24 25exit(status) 26