[icinga-checkins] icinga.org: icinga2/master: Bugfix: Don't leak lock file' s fd into child processes.

git at icinga.org git at icinga.org
Fri Feb 8 10:23:13 CET 2013


Module: icinga2
Branch: master
Commit: 513b3d682057c3c13f3307a438a7ff88f6777cf7
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=513b3d682057c3c13f3307a438a7ff88f6777cf7

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Fri Feb  8 10:23:01 2013 +0100

Bugfix: Don't leak lock file's fd into child processes.

---

 lib/base/application.cpp |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/lib/base/application.cpp b/lib/base/application.cpp
index dcc4e5a..e34f2fc 100644
--- a/lib/base/application.cpp
+++ b/lib/base/application.cpp
@@ -458,6 +458,16 @@ void Application::UpdatePidFile(const String& filename)
 	if (m_PidFile == NULL)
 		BOOST_THROW_EXCEPTION(runtime_error("Could not open PID file '" + filename + "'"));
 
+#ifdef F_GETFL
+		int flags;
+		flags = fcntl(fd, F_GETFL, 0);
+		if (flags < 0)
+			BOOST_THROW_EXCEPTION(PosixException("fcntl failed", errno));
+
+		if (fcntl(fd, F_SETFL, flags | FD_CLOEXEC) < 0)
+			BOOST_THROW_EXCEPTION(PosixException("fcntl failed", errno));
+#endif /* FD_CLOEXEC */
+
 #ifndef _WIN32
 	if (flock(fileno(m_PidFile), LOCK_EX | LOCK_NB) < 0) {
 		ClosePidFile();
@@ -576,4 +586,3 @@ void Application::SetPkgDataDir(const String& path)
 {
         m_PkgDataDir = path;
 }
-





More information about the icinga-checkins mailing list