From b82a13c4677d77f6af129625a322473dd9c4bdf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Tue, 16 Jul 2019 14:23:40 +0300 Subject: [PATCH] Exit gracefully with an error code whenever backend exits --- ethermess.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ethermess.py b/ethermess.py index e428dee..6c44eb8 100644 --- a/ethermess.py +++ b/ethermess.py @@ -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))