Commit e322db1f authored by Vangelis Koukis's avatar Vangelis Koukis
Browse files

Add SIGTERM handling to vncauthproxy

Install a signal handler for fatal signals using gevent.signal().
This allows vncauthproxy to unlink its control socket and exit
gracefully when SIGTERM is received.
parent ce2cfc7b
......@@ -27,8 +27,11 @@ import gevent
import rfb
from gevent import socket
from signal import SIGTERM
from gevent import signal
from import select
class VncAuthProxy(gevent.Greenlet):
Simple class implementing a VNC Forwarder with MITM authentication as a
......@@ -309,6 +312,11 @@ class VncAuthProxy(gevent.Greenlet):
def fatal_signal_handler(signame):"Caught %s, will raise SystemExit" % signame)
raise SystemExit
if __name__ == '__main__':
from optparse import OptionParser
......@@ -350,10 +358,17 @@ if __name__ == '__main__':"Initalized, waiting for control connections at %s" %
# Catch SIGTERM to ensure graceful shutdown,
# e.g., to make sure the control socket gets unlink()ed.
# Uses gevent.signal so the handler fires even during
# gevent.socket.accept()
gevent.signal(SIGTERM, fatal_signal_handler, "SIGTERM")
while True:
client, addr = ctrl.accept()
except KeyboardInterrupt:
except (KeyboardInterrupt, SystemExit):
break"New control connection")
......@@ -379,5 +394,7 @@ if __name__ == '__main__':
VncAuthProxy.spawn(sport, daddr, dport, password, opts.connect_timeout)
client.close()"Unlinking control socket at %s" %
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment