]> granicus.if.org Git - icinga2/commitdiff
Compile fix for *NIX.
authorGunnar Beutner <gunnar@beutner.name>
Sun, 24 Jun 2012 14:32:50 +0000 (16:32 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Sun, 24 Jun 2012 14:33:51 +0000 (16:33 +0200)
icinga/i2-icinga.h
icinga/nagioschecktask.cpp
icinga/nagioschecktask.h

index 45cf6be84981a2e0e8606461ad917b64c36d5c6f..e831b2b26c884f6a95861d7235b8a4e07e3f7f46 100644 (file)
 #include <i2-jsonrpc.h>
 #include <set>
 
+#ifndef _MSC_VER
+#      include "popen_noshell.h"
+#endif /* _MSC_VER */
+
 #include <boost/thread/future.hpp>
 using boost::packaged_task;
 using boost::unique_future;
index f2901b9be9a5937aee4ca51210f08cdb0ad7af69..97fb586772005981521244cfda3d0d9e346e2bba 100644 (file)
@@ -1,7 +1,4 @@
 #include "i2-icinga.h"
-#ifndef _MSC_VER
-#      include "popen_noshell.h"
-#endif /* _MSC_VER */
 
 using namespace icinga;
 
@@ -10,7 +7,7 @@ deque<NagiosCheckTask::Ptr> NagiosCheckTask::m_Tasks;
 condition_variable NagiosCheckTask::m_TasksCV;
 
 NagiosCheckTask::NagiosCheckTask(const Service& service)
-       : CheckTask(service), m_FP(NULL)
+       : CheckTask(service), m_FP(NULL), m_UsePopen(false)
 {
        string checkCommand = service.GetCheckCommand();
        m_Command = MacroProcessor::ResolveMacros(checkCommand, service.GetMacros()); // + " 2>&1";
@@ -108,18 +105,14 @@ bool NagiosCheckTask::InitTask(void)
 #ifdef _MSC_VER
        m_FP = _popen(m_Command.c_str(), "r");
 #else /* _MSC_VER */
-       bool use_libc_popen = false;
-
-       popen_noshell_pass_to_pclose pclose_arg;
-
-       if (!use_libc_popen) {
-               m_FP = popen_noshell_compat(m_Command.c_str(), "r", &pclose_arg);
+       if (!m_UsePopen) {
+               m_FP = popen_noshell_compat(m_Command.c_str(), "r", &m_PCloseArg);
 
                if (m_FP == NULL) // TODO: add check for valgrind
-                       use_libc_popen = true;
+                       m_UsePopen = true;
        }
 
-       if (use_libc_popen)
+       if (m_UsePopen)
                m_FP = popen(m_Command.c_str(), "r");
 #endif /* _MSC_VER */
 
@@ -144,10 +137,10 @@ bool NagiosCheckTask::RunTask(void)
 #ifdef _MSC_VER
        status = _pclose(m_FP);
 #else /* _MSC_VER */
-       if (use_libc_popen)
+       if (m_UsePopen)
                status = pclose(fp);
        else
-               status = pclose_noshell(&pclose_arg);
+               status = pclose_noshell(&m_PCloseArg);
 #endif /* _MSC_VER */
 
 #ifndef _MSC_VER
index d850ad8cfd4417b0b64f65f0655c798144ab7a14..ef46d079fc0a421c10a16933bc4675f6f0eaec92 100644 (file)
@@ -26,6 +26,8 @@ private:
 
        FILE *m_FP;
        stringstream m_OutputStream;
+       bool m_UsePopen;
+       popen_noshell_pass_to_pclose m_PCloseArg;
 
        static boost::mutex m_Mutex;
        static deque<NagiosCheckTask::Ptr> m_Tasks;