mirror of
https://github.com/clang-retro/picolibc.git
synced 2026-11-28 21:29:27 -08:00
Don't crash the wrapper when the app generates non-utf-8 sequences. Signed-off-by: Keith Packard <keithp@keithp.com>
32 lines
903 B
Python
Executable File
32 lines
903 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import os
|
|
import sys
|
|
import subprocess
|
|
|
|
status = 1
|
|
|
|
with subprocess.Popen(sys.argv[1:], stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc:
|
|
while True:
|
|
status = proc.poll()
|
|
if status:
|
|
break;
|
|
c = proc.stdout.read(1)
|
|
if c == b'\xe9':
|
|
line = proc.stdout.readline().decode('utf-8', errors='ignore')
|
|
words = line.split()
|
|
if len(words) > 0:
|
|
if words[0] == 'exit':
|
|
proc.send_signal(1)
|
|
status = int(words[1])
|
|
if status >= 128:
|
|
status = status | 1
|
|
break
|
|
sys.stdout.write(c.decode('utf-8', errors='ignore'))
|
|
stderr = proc.stderr.read()
|
|
for line in stderr.strip().split(b'\n'):
|
|
if b'terminating on signal' not in line:
|
|
print(line)
|
|
|
|
exit(status)
|