[icinga-checkins] icinga.org: icinga2/master: Fixed another file descriptor leak.

git at icinga.org git at icinga.org
Wed Feb 13 12:34:31 CET 2013


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

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Wed Feb 13 12:34:25 2013 +0100

Fixed another file descriptor leak.

---

 lib/base/process-unix.cpp |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/lib/base/process-unix.cpp b/lib/base/process-unix.cpp
index f2ad379..b74c1b7 100644
--- a/lib/base/process-unix.cpp
+++ b/lib/base/process-unix.cpp
@@ -35,6 +35,14 @@ void Process::CreateWorkers(void)
 
 	m_TaskFd = fds[1];
 
+	int flags;
+	flags = fcntl(fds[1], F_GETFL, 0);
+	if (flags < 0)
+		BOOST_THROW_EXCEPTION(PosixException("fcntl failed", errno));
+
+	if (fcntl(fds[1], F_SETFL, flags | O_NONBLOCK | O_CLOEXEC) < 0)
+		BOOST_THROW_EXCEPTION(PosixException("fcntl failed", errno));
+
 	for (int i = 0; i < thread::hardware_concurrency(); i++) {
 		int childTaskFd;
 
@@ -54,6 +62,8 @@ void Process::CreateWorkers(void)
 		thread t(&Process::WorkerThreadProc, childTaskFd);
 		t.detach();
 	}
+
+	(void) close(fds[0]);
 }
 
 void Process::WorkerThreadProc(int taskFd)





More information about the icinga-checkins mailing list