From ec3a696a5d328936b611b2a19fc9ab12ae183b48 Mon Sep 17 00:00:00 2001 From: liushi Date: Mon, 23 Dec 2019 17:09:29 +0800 Subject: [PATCH] mgr: close restful socket after exec Signed-off-by: liushi --- src/pybind/mgr/restful/module.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pybind/mgr/restful/module.py b/src/pybind/mgr/restful/module.py index 0f8257b7bed..098258b06ff 100644 --- a/src/pybind/mgr/restful/module.py +++ b/src/pybind/mgr/restful/module.py @@ -13,6 +13,7 @@ import threading import traceback import six import socket +import fcntl from . import common from . import context @@ -331,6 +332,10 @@ class Module(MgrModule): ), ssl_context=(cert_fname, pkey_fname), ) + sock_fd_flag = fcntl.fcntl(self.server.socket.fileno(), fcntl.F_GETFD) + if not (sock_fd_flag & fcntl.FD_CLOEXEC): + self.log.debug("set server socket close-on-exec") + fcntl.fcntl(self.server.socket.fileno(), fcntl.F_SETFD, sock_fd_flag | fcntl.FD_CLOEXEC) if self.stop_server: self.log.debug('made server, but stop flag set') else: -- 2.39.5