From ec451b5908558388608be6bc94794ee4c9f77b81 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 30 Mar 2020 10:36:24 +0200 Subject: [PATCH] fix(command): check WIFEXITED --- include/util/command.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/util/command.hpp b/include/util/command.hpp index 8db7bfba..f3dd4e1a 100644 --- a/include/util/command.hpp +++ b/include/util/command.hpp @@ -72,7 +72,10 @@ inline struct res exec(std::string cmd) { if (!fp) return {-1, ""}; auto output = command::read(fp); auto stat = command::close(fp, pid); - return {WEXITSTATUS(stat), output}; + if (WIFEXITED(stat)) { + return {WEXITSTATUS(stat), output}; + } + return {-1, output}; } inline int32_t forkExec(std::string cmd) {