]> granicus.if.org Git - icinga2/commitdiff
Fixed another file descriptor leak.
authorGunnar Beutner <gunnar.beutner@netways.de>
Wed, 13 Feb 2013 11:34:25 +0000 (12:34 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Wed, 13 Feb 2013 11:34:25 +0000 (12:34 +0100)
lib/base/process-unix.cpp

index f2ad37914f8f6fd639f230d46a0620e81fc1745e..b74c1b79f667fb7b9fa8dbbfd2b9a14b9444594a 100644 (file)
@@ -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)