diff --git a/trezor_agent/gpg/__main__.py b/trezor_agent/gpg/__main__.py index 4aa92b6..5f6a5b5 100755 --- a/trezor_agent/gpg/__main__.py +++ b/trezor_agent/gpg/__main__.py @@ -112,6 +112,9 @@ def main_agent(): with contextlib.closing(conn): try: agent.handle_connection(conn) + except StopIteration: + log.info('stopping gpg-agent') + return except Exception as e: # pylint: disable=broad-except log.exception('gpg-agent failed: %s', e) diff --git a/trezor_agent/gpg/agent.py b/trezor_agent/gpg/agent.py index 22b6f31..b4ae5a0 100644 --- a/trezor_agent/gpg/agent.py +++ b/trezor_agent/gpg/agent.py @@ -142,6 +142,9 @@ def handle_connection(conn): keyring.sendline(conn, fmt.format(keygrip).encode('ascii')) elif command == b'BYE': return + elif command == b'KILLAGENT': + keyring.sendline(conn, b'OK') + raise StopIteration else: log.error('unknown request: %r', line) return