From ba4d550fec8b36bfbfa44bbfc757cab094d3dbc8 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sun, 24 Jun 2012 16:39:49 +0200 Subject: [PATCH] Even more fixes. --- icinga/i2-icinga.h | 4 ---- icinga/nagioschecktask.cpp | 16 ++++++++++++---- icinga/nagioschecktask.h | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/icinga/i2-icinga.h b/icinga/i2-icinga.h index e831b2b26..45cf6be84 100644 --- a/icinga/i2-icinga.h +++ b/icinga/i2-icinga.h @@ -31,10 +31,6 @@ #include #include -#ifndef _MSC_VER -# include "popen_noshell.h" -#endif /* _MSC_VER */ - #include using boost::packaged_task; using boost::unique_future; diff --git a/icinga/nagioschecktask.cpp b/icinga/nagioschecktask.cpp index ceb0fdcf7..d0452b00e 100644 --- a/icinga/nagioschecktask.cpp +++ b/icinga/nagioschecktask.cpp @@ -1,5 +1,9 @@ #include "i2-icinga.h" +#ifndef _MSC_VER +# include "popen_noshell.h" +#endif /* _MSC_VER */ + using namespace icinga; boost::mutex NagiosCheckTask::m_Mutex; @@ -108,7 +112,9 @@ bool NagiosCheckTask::InitTask(void) m_FP = _popen(m_Command.c_str(), "r"); #else /* _MSC_VER */ if (!m_UsePopen) { - m_FP = popen_noshell_compat(m_Command.c_str(), "r", &m_PCloseArg); + m_PCloseArg = new popen_noshell_pass_to_pclose; + + m_FP = popen_noshell_compat(m_Command.c_str(), "r", (popen_noshell_pass_to_pclose *)m_PCloseArg); if (m_FP == NULL) // TODO: add check for valgrind m_UsePopen = true; @@ -139,10 +145,12 @@ bool NagiosCheckTask::RunTask(void) #ifdef _MSC_VER status = _pclose(m_FP); #else /* _MSC_VER */ - if (m_UsePopen) + if (m_UsePopen) { status = pclose(m_FP); - else - status = pclose_noshell(&m_PCloseArg); + } else { + status = pclose_noshell((popen_noshell_pass_to_pclose *)m_PCloseArg); + delete (popen_noshell_pass_to_pclose *)m_PCloseArg; + } #endif /* _MSC_VER */ #ifndef _MSC_VER diff --git a/icinga/nagioschecktask.h b/icinga/nagioschecktask.h index ee4ca9fcc..c0601c373 100644 --- a/icinga/nagioschecktask.h +++ b/icinga/nagioschecktask.h @@ -28,7 +28,7 @@ private: stringstream m_OutputStream; bool m_UsePopen; #ifndef _MSC_VER - popen_noshell_pass_to_pclose m_PCloseArg; + void *m_PCloseArg; #endif /* _MSC_VER */ static boost::mutex m_Mutex;