Exit gracefully with an error code whenever backend exits

This commit is contained in:
Juhani Krekelä 2019-07-16 14:23:40 +03:00
parent 4280c3f052
commit b82a13c467
1 changed files with 6 additions and 2 deletions

View File

@ -511,7 +511,7 @@ def eventloop(proc):
elif fd == proc.stdout.fileno() and event & select.POLLHUP:
print('--- Backend exited')
running = False
sys.exit(1)
elif fd == unbuf_stdin.fileno() and event & select.POLLIN:
data = unbuf_stdin.read(1024)
@ -557,7 +557,11 @@ def main():
writeall(proc.stdin, bytes([own_status.value, len(encoded)]) + encoded)
# Read our MAC
mac = readall(proc.stdout, 6)
try:
mac = readall(proc.stdout, 6)
except ReadallError:
print('--- Backend exited')
sys.exit(1)
print('--- MAC: %s' % format_mac(mac))