diff --git a/src/cpp-utils/process/subprocess.cpp b/src/cpp-utils/process/subprocess.cpp index fcf740b0..00f6c80c 100644 --- a/src/cpp-utils/process/subprocess.cpp +++ b/src/cpp-utils/process/subprocess.cpp @@ -1,7 +1,16 @@ #include "subprocess.h" #include #include + +#if !defined(_MSC_VER) #include +constexpr const char* openmode = "re"; +#else +#define popen _popen +#define pclose _pclose +#define WEXITSTATUS(a) a +constexpr const char* openmode = "r"; +#endif using std::string; @@ -33,7 +42,7 @@ namespace cpputils { } FILE *Subprocess::_call(const string &command) { - FILE *subprocess = popen(command.c_str(), "r"); + FILE *subprocess = popen(command.c_str(), openmode); if (!subprocess) { throw std::runtime_error("Error starting subprocess "+command);