fix(command): check WIFEXITED

pull/651/head
Alex 2020-03-30 10:36:24 +02:00
parent ae3d4b9d28
commit ec451b5908
1 changed files with 4 additions and 1 deletions

View File

@ -72,8 +72,11 @@ inline struct res exec(std::string cmd) {
if (!fp) return {-1, ""}; if (!fp) return {-1, ""};
auto output = command::read(fp); auto output = command::read(fp);
auto stat = command::close(fp, pid); auto stat = command::close(fp, pid);
if (WIFEXITED(stat)) {
return {WEXITSTATUS(stat), output}; return {WEXITSTATUS(stat), output};
} }
return {-1, output};
}
inline int32_t forkExec(std::string cmd) { inline int32_t forkExec(std::string cmd) {
if (cmd == "") return -1; if (cmd == "") return -1;