add a simplest SIGCHLD handler in order to avoid zombies in the docker container governed by the script

This commit is contained in:
Oleksii Kliukin
2015-05-13 10:05:12 +02:00
parent 127a03d23d
commit 8ad751b661
+9
View File
@@ -19,6 +19,14 @@ 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:
os.waitpid(-1, os.WNOHANG)
except OSError:
pass
class Governor:
INSTANCE_METADATA_URL = "http://169.254.169.254/latest/meta-data/"
@@ -96,4 +104,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()