- Added signal handling. There is a bug with join() and signal handling in Python.

https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1167930&group_id=5470

git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/trunk@436 a942ae1a-1317-0410-a47c-b1dcaea8d605
0.x
Cyril Jaquier 2006-10-30 22:47:30 +00:00
parent 9f44b18a2f
commit ae0ed204ee
2 changed files with 15 additions and 1 deletions

View File

@ -20,6 +20,8 @@ ver. 0.7.4 (2006/??/??) - beta
- Improved testing framework
- Fixed a bug in the return code handling of the executed
commands. Thanks to Yaroslav Halchenko
- Signal handling. There is a bug with join() and signal in
Python
ver. 0.7.3 (2006/09/28) - beta
----------

View File

@ -46,8 +46,17 @@ class Server:
self.setLogLevel(self.__logLevel)
self.setLogTarget(self.__logTarget)
def __sigTERMhandler(self, signum, frame):
logSys.debug("Caught signal %d. Exiting" % signum)
self.quit()
def start(self, sock, force = False):
logSys.info("Starting Fail2ban")
# Install signal handlers
signal.signal(signal.SIGTERM, self.__sigTERMhandler)
signal.signal(signal.SIGINT, self.__sigTERMhandler)
# First set the mask to only allow access to owner
os.umask(0077)
if self.__daemon:
@ -62,7 +71,10 @@ class Server:
try:
self.__socket.initialize(sock, force)
self.__socket.start()
self.__socket.join()
# Workaround (???) for join() bug.
# https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1167930&group_id=5470
while self.__socket.isAlive():
self.__socket.join(1)
except SSocketErrorException:
logSys.error("Could not start server")
logSys.info("Exiting Fail2ban")