Handle sigchld, so we can run governor and postgres inside docker safely

This commit is contained in:
Alexander Kukushkin
2015-05-13 18:05:42 +02:00
parent e6e19359df
commit 4e8a0873a7
+12
View File
@@ -16,6 +16,17 @@ def sigterm_handler(signo, stack_frame):
sys.exit()
# handle SIGCHILD, since we are the equivalent of the INIT process
def sigchld_handler(signo, stack_frame):
try:
while True:
ret = os.waitpid(-1, os.WNOHANG)
if ret == (0, 0):
break
except OSError:
pass
class Governor:
def __init__(self, config):
@@ -78,4 +89,5 @@ def main():
if __name__ == '__main__':
logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=logging.INFO)
signal.signal(signal.SIGTERM, sigterm_handler)
signal.signal(signal.SIGCHLD, sigchld_handler)
main()