Fix subprocess for osx
This commit is contained in:
parent
ca68102a50
commit
dfd6a0414f
@ -3,14 +3,23 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
|
||||||
#if !defined(_MSC_VER)
|
#if defined(__APPLE__)
|
||||||
|
|
||||||
|
#include <sys/wait.h>
|
||||||
|
constexpr const char* openmode = "r";
|
||||||
|
|
||||||
|
#elif !defined(_MSC_VER)
|
||||||
|
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
constexpr const char* openmode = "re";
|
constexpr const char* openmode = "re";
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define popen _popen
|
#define popen _popen
|
||||||
#define pclose _pclose
|
#define pclose _pclose
|
||||||
#define WEXITSTATUS(a) a
|
#define WEXITSTATUS(a) a
|
||||||
constexpr const char* openmode = "r";
|
constexpr const char* openmode = "r";
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
@ -23,7 +32,7 @@ namespace cpputils {
|
|||||||
FILE *subprocess = popen(command.c_str(), openmode);
|
FILE *subprocess = popen(command.c_str(), openmode);
|
||||||
if (!subprocess)
|
if (!subprocess)
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Error starting subprocess "+command);
|
throw std::runtime_error("Error starting subprocess "+command + ". Errno: " + std::to_string(errno));
|
||||||
}
|
}
|
||||||
return subprocess;
|
return subprocess;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user