1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

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

This commit is contained in:
Marcelo Fernandez
2017-09-21 17:44:53 -03:00
parent 1391269a78
commit 253db95cba
7 changed files with 12 additions and 8 deletions

View File

@@ -330,7 +330,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) {
@@ -342,7 +342,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);