(cherry picked from commit 0d3a168a532349d0759a033b04efe04e5ef72c32)
@@ -357,7 +357,7 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo
int status;
waitpid(pid, &status, 0);
if (r_exitcode)
- *r_exitcode = WEXITSTATUS(status);
+ *r_exitcode = WIFEXITED(status) ? WEXITSTATUS(status) : status;
} else {