Skip to content

Commit

Permalink
revocation notifier: handle shutdown of process gracefully
Browse files Browse the repository at this point in the history
Signed-off-by: Thore Sommer <mail@thson.de>
  • Loading branch information
THS-on committed Jan 7, 2022
1 parent 0458452 commit 3650a86
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions keylime/revocation_notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import time
import os
import sys
import signal

import requests
import zmq
Expand Down Expand Up @@ -39,8 +38,10 @@ def worker():
f"tcp://{config.get('cloud_verifier', 'revocation_notifier_ip')}:"
f"{config.getint('cloud_verifier', 'revocation_notifier_port')}"
)

zmq.device(zmq.FORWARDER, frontend, backend)
try:
zmq.device(zmq.FORWARDER, frontend, backend)
except (KeyboardInterrupt, SystemExit):
context.destroy()

global broker_proc
broker_proc = Process(target=worker)
Expand All @@ -53,7 +54,9 @@ def stop_broker():
# Remove the socket file before we kill the process
if os.path.exists("/tmp/keylime.verifier.ipc"):
os.remove("/tmp/keylime.verifier.ipc")
os.kill(broker_proc.pid, signal.SIGKILL)
logger.info("Stopping revocation notifier...")
broker_proc.terminate()
broker_proc.join()


def notify(tosend):
Expand Down

0 comments on commit 3650a86

Please sign in to comment.