mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 13:45:04 +02:00
Compile fix for *NIX.
This commit is contained in:
parent
833ede8b3a
commit
65ecfc7d57
@ -31,6 +31,10 @@
|
|||||||
#include <i2-jsonrpc.h>
|
#include <i2-jsonrpc.h>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
|
#ifndef _MSC_VER
|
||||||
|
# include "popen_noshell.h"
|
||||||
|
#endif /* _MSC_VER */
|
||||||
|
|
||||||
#include <boost/thread/future.hpp>
|
#include <boost/thread/future.hpp>
|
||||||
using boost::packaged_task;
|
using boost::packaged_task;
|
||||||
using boost::unique_future;
|
using boost::unique_future;
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
#include "i2-icinga.h"
|
#include "i2-icinga.h"
|
||||||
#ifndef _MSC_VER
|
|
||||||
# include "popen_noshell.h"
|
|
||||||
#endif /* _MSC_VER */
|
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
@ -10,7 +7,7 @@ deque<NagiosCheckTask::Ptr> NagiosCheckTask::m_Tasks;
|
|||||||
condition_variable NagiosCheckTask::m_TasksCV;
|
condition_variable NagiosCheckTask::m_TasksCV;
|
||||||
|
|
||||||
NagiosCheckTask::NagiosCheckTask(const Service& service)
|
NagiosCheckTask::NagiosCheckTask(const Service& service)
|
||||||
: CheckTask(service), m_FP(NULL)
|
: CheckTask(service), m_FP(NULL), m_UsePopen(false)
|
||||||
{
|
{
|
||||||
string checkCommand = service.GetCheckCommand();
|
string checkCommand = service.GetCheckCommand();
|
||||||
m_Command = MacroProcessor::ResolveMacros(checkCommand, service.GetMacros()); // + " 2>&1";
|
m_Command = MacroProcessor::ResolveMacros(checkCommand, service.GetMacros()); // + " 2>&1";
|
||||||
@ -108,18 +105,14 @@ bool NagiosCheckTask::InitTask(void)
|
|||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
m_FP = _popen(m_Command.c_str(), "r");
|
m_FP = _popen(m_Command.c_str(), "r");
|
||||||
#else /* _MSC_VER */
|
#else /* _MSC_VER */
|
||||||
bool use_libc_popen = false;
|
if (!m_UsePopen) {
|
||||||
|
m_FP = popen_noshell_compat(m_Command.c_str(), "r", &m_PCloseArg);
|
||||||
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_FP == NULL) // TODO: add check for valgrind
|
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");
|
m_FP = popen(m_Command.c_str(), "r");
|
||||||
#endif /* _MSC_VER */
|
#endif /* _MSC_VER */
|
||||||
|
|
||||||
@ -144,10 +137,10 @@ bool NagiosCheckTask::RunTask(void)
|
|||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
status = _pclose(m_FP);
|
status = _pclose(m_FP);
|
||||||
#else /* _MSC_VER */
|
#else /* _MSC_VER */
|
||||||
if (use_libc_popen)
|
if (m_UsePopen)
|
||||||
status = pclose(fp);
|
status = pclose(fp);
|
||||||
else
|
else
|
||||||
status = pclose_noshell(&pclose_arg);
|
status = pclose_noshell(&m_PCloseArg);
|
||||||
#endif /* _MSC_VER */
|
#endif /* _MSC_VER */
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
|
@ -26,6 +26,8 @@ private:
|
|||||||
|
|
||||||
FILE *m_FP;
|
FILE *m_FP;
|
||||||
stringstream m_OutputStream;
|
stringstream m_OutputStream;
|
||||||
|
bool m_UsePopen;
|
||||||
|
popen_noshell_pass_to_pclose m_PCloseArg;
|
||||||
|
|
||||||
static boost::mutex m_Mutex;
|
static boost::mutex m_Mutex;
|
||||||
static deque<NagiosCheckTask::Ptr> m_Tasks;
|
static deque<NagiosCheckTask::Ptr> m_Tasks;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user