Commit 6827c280 authored by Guido van Rossum's avatar Guido van Rossum

Fix a problem in rotate_logs_handler(), caused by my changing the

signal meanings: rotate_logs_handler() was changing the SIGHUP handler
to rotate the logs!  zdaemon did not do anything wrong. :-)
Fixed by *removing* the signal() call inside the handler -- this is
not needed in modern Unixes.

Also changed setup_signals(): there was a typo in the name SIFXFSZ(!);
and made all the signal conditional on whether the signal module has
that particular signal (e.g. on Windows, a signal module exists, but
it only defines a few signals).
parent aeb99a80
...@@ -81,18 +81,14 @@ def setup_signals(storages): ...@@ -81,18 +81,14 @@ def setup_signals(storages):
except ImportError: except ImportError:
return return
try: if hasattr(signal, 'SIGXFSZ'):
xfsz = signal.SIFXFSZ signal.signal(signal.SIGXFSZ, signal.SIG_IGN)
except AttributeError: if hasattr(signal, 'SIGTERM'):
pass
else:
signal.signal(xfsz, signal.SIG_IGN)
signal.signal(signal.SIGTERM, lambda sig, frame: shutdown(storages)) signal.signal(signal.SIGTERM, lambda sig, frame: shutdown(storages))
if hasattr(signal, 'SIGHUP'):
signal.signal(signal.SIGHUP, lambda sig, frame: shutdown(storages, 0)) signal.signal(signal.SIGHUP, lambda sig, frame: shutdown(storages, 0))
try: if hasattr(signal, 'SIGUSR2'):
signal.signal(signal.SIGUSR2, rotate_logs_handler) signal.signal(signal.SIGUSR2, rotate_logs_handler)
except:
pass
def main(argv): def main(argv):
me = argv[0] me = argv[0]
...@@ -316,9 +312,6 @@ def rotate_logs(): ...@@ -316,9 +312,6 @@ def rotate_logs():
def rotate_logs_handler(signum, frame): def rotate_logs_handler(signum, frame):
rotate_logs() rotate_logs()
import signal
signal.signal(signal.SIGHUP, rotate_logs_handler)
def shutdown(storages, die=1): def shutdown(storages, die=1):
LOG("ZEO/start.py", INFO, "Received signal") LOG("ZEO/start.py", INFO, "Received signal")
import asyncore import asyncore
......
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