From 2511b0ed725cbfdd7d3e6ba1fc5544ad0ec583b4 Mon Sep 17 00:00:00 2001 From: Livanh Date: Fri, 30 Nov 2018 11:47:26 +0100 Subject: [PATCH] Avoid possible race condition between SIGTERM and SIGHUP --- supervisor/supervisord.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/supervisor/supervisord.py b/supervisor/supervisord.py index e132f6575..af7228641 100755 --- a/supervisor/supervisord.py +++ b/supervisor/supervisord.py @@ -292,9 +292,13 @@ def handle_signal(self): 'received %s indicating exit request' % signame(sig)) self.options.mood = SupervisorStates.SHUTDOWN elif sig == signal.SIGHUP: - self.options.logger.warn( - 'received %s indicating restart request' % signame(sig)) - self.options.mood = SupervisorStates.RESTARTING + if self.options.mood == SupervisorStates.SHUTDOWN: + self.options.logger.warn( + 'ignored %s indicating restart request (shutdown in progress)' % signame(sig)) + else: + self.options.logger.warn( + 'received %s indicating restart request' % signame(sig)) + self.options.mood = SupervisorStates.RESTARTING elif sig == signal.SIGCHLD: self.options.logger.debug( 'received %s indicating a child quit' % signame(sig))