1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-12 13:20:55 +00:00

OS::execute can now read from stderr too when executing with a pipe

This commit is contained in:
Marcelo Fernandez
2017-10-03 15:09:04 -03:00
parent c5ab18f33e
commit 4b695c3bdf
7 changed files with 12 additions and 8 deletions

View File

@@ -285,7 +285,7 @@ uint64_t OS_Unix::get_ticks_usec() const {
return longtime;
}
Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode) {
Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id, String *r_pipe, int *r_exitcode, bool read_stderr) {
if (p_blocking && r_pipe) {
@@ -297,7 +297,11 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, bo
argss += String(" \"") + p_arguments[i] + "\"";
}
argss += " 2>/dev/null"; //silence stderr
if (read_stderr) {
argss += " 2>&1"; // Read stderr too
} else {
argss += " 2>/dev/null"; //silence stderr
}
FILE *f = popen(argss.utf8().get_data(), "r");
ERR_FAIL_COND_V(!f, ERR_CANT_OPEN);