diff -r bc88690df059 Lib/cgi.py --- a/Lib/cgi.py Tue Jan 29 13:35:00 2013 +0100 +++ b/Lib/cgi.py Tue Jan 29 14:00:31 2013 +0100 @@ -79,7 +79,7 @@ def initlog(*allargs): global log, logfile, logfp if logfile and not logfp: try: - logfp = open(logfile, "a") + logfp = open(logfile, "a", cloexec=True) except OSError: pass if not logfp: diff -r bc88690df059 Lib/logging/__init__.py --- a/Lib/logging/__init__.py Tue Jan 29 13:35:00 2013 +0100 +++ b/Lib/logging/__init__.py Tue Jan 29 14:00:31 2013 +0100 @@ -994,7 +994,9 @@ class FileHandler(StreamHandler): Open the current base file with the (original) mode and encoding. Return the resulting stream. """ - return open(self.baseFilename, self.mode, encoding=self.encoding) + return open(self.baseFilename, self.mode, + encoding=self.encoding, + cloexec=True) def emit(self, record): """