Fix subprocess for Windows
This commit is contained in:
parent
2ea77d4c26
commit
aa4e3c7c08
@ -18,6 +18,7 @@ constexpr const char* openmode = "re";
|
|||||||
#define popen _popen
|
#define popen _popen
|
||||||
#define pclose _pclose
|
#define pclose _pclose
|
||||||
#define WEXITSTATUS(a) a
|
#define WEXITSTATUS(a) a
|
||||||
|
#define WIFEXITED(a) true
|
||||||
constexpr const char* openmode = "r";
|
constexpr const char* openmode = "r";
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -51,8 +52,8 @@ namespace cpputils {
|
|||||||
if(returncode == -1) {
|
if(returncode == -1) {
|
||||||
throw std::runtime_error("Error calling pclose. Errno: " + std::to_string(errno));
|
throw std::runtime_error("Error calling pclose. Errno: " + std::to_string(errno));
|
||||||
}
|
}
|
||||||
if (WIFEXITED(returncode) == 0) {
|
if (!WIFEXITED(returncode)) {
|
||||||
// WEXITSTATUS is only valud if WIFEXITED is 0.
|
// WEXITSTATUS is only valid if WIFEXITED is 0.
|
||||||
throw std::runtime_error("WIFEXITED returned " + std::to_string(WIFEXITED(returncode)));
|
throw std::runtime_error("WIFEXITED returned " + std::to_string(WIFEXITED(returncode)));
|
||||||
}
|
}
|
||||||
return WEXITSTATUS(returncode);
|
return WEXITSTATUS(returncode);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user