From 9e465c9fd0a5771d870e3550958b63ebbe992ca7 Mon Sep 17 00:00:00 2001 From: Luis Martinez Date: Fri, 1 Mar 2019 16:51:53 -0600 Subject: [PATCH] Fixes stderr silence; adds missing quote from exe args(windows) https://github.com/godotengine/godot/blob/8d117b214f2bcd14015532fdfbed9b3f059da0e6/core/bind/core_bind.cpp#L452 This function calls the bottom function https://github.com/godotengine/godot/blob/8d117b214f2bcd14015532fdfbed9b3f059da0e6/drivers/unix/os_unix.cpp#L312 OS.execute doesn't send out a value to stderr, so stderr defaults to false, which will invoke this bottom line and always silence stderr. https://github.com/godotengine/godot/blob/8d117b214f2bcd14015532fdfbed9b3f059da0e6/drivers/unix/os_unix.cpp#L315 Some programs, such as FFmpeg, will print out to stderr with valuable and vital information. This fixes stderr always being silenced, user can now opt to have it be read as normal. --- core/bind/core_bind.cpp | 6 +++--- core/bind/core_bind.h | 2 +- platform/windows/os_windows.cpp | 8 +++++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index f6828ea76aba..15e0da4f4b28 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -442,14 +442,14 @@ Error _OS::shell_open(String p_uri) { return OS::get_singleton()->shell_open(p_uri); }; -int _OS::execute(const String &p_path, const Vector &p_arguments, bool p_blocking, Array p_output) { +int _OS::execute(const String &p_path, const Vector &p_arguments, bool p_blocking, Array p_output, bool p_read_stderr) { OS::ProcessID pid = -2; List args; for (int i = 0; i < p_arguments.size(); i++) args.push_back(p_arguments[i]); String pipe; - Error err = OS::get_singleton()->execute(p_path, args, p_blocking, &pid, &pipe); + Error err = OS::get_singleton()->execute(p_path, args, p_blocking, &pid, &pipe, NULL, p_read_stderr); p_output.clear(); p_output.push_back(pipe); if (err != OK) @@ -1173,7 +1173,7 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("get_processor_count"), &_OS::get_processor_count); ClassDB::bind_method(D_METHOD("get_executable_path"), &_OS::get_executable_path); - ClassDB::bind_method(D_METHOD("execute", "path", "arguments", "blocking", "output"), &_OS::execute, DEFVAL(Array())); + ClassDB::bind_method(D_METHOD("execute", "path", "arguments", "blocking", "output", "read_stderr"), &_OS::execute, DEFVAL(Array()), DEFVAL(false)); ClassDB::bind_method(D_METHOD("kill", "pid"), &_OS::kill); ClassDB::bind_method(D_METHOD("shell_open", "uri"), &_OS::shell_open); ClassDB::bind_method(D_METHOD("get_process_id"), &_OS::get_process_id); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index f3bc4644d8f0..c47f8bd4fc50 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -214,7 +214,7 @@ public: bool is_in_low_processor_usage_mode() const; String get_executable_path() const; - int execute(const String &p_path, const Vector &p_arguments, bool p_blocking, Array p_output = Array()); + int execute(const String &p_path, const Vector &p_arguments, bool p_blocking, Array p_output = Array(), bool p_read_stderr = false); Error kill(int p_pid); Error shell_open(String p_uri); diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 61aeb3ec9334..c79e926329be 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -2451,7 +2451,13 @@ Error OS_Windows::execute(const String &p_path, const List &p_arguments, for (const List::Element *E = p_arguments.front(); E; E = E->next()) { - argss += String(" \"") + E->get() + "\""; + argss += " \"" + E->get() + "\""; + } + + argss += "\""; + + if (read_stderr) { + argss += " 2>&1"; // Read stderr too } FILE *f = _wpopen(argss.c_str(), L"r");