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

Improve return value of OS.execute in blocking/non-blocking variants

Initialized the PID to -2, which will be the value returns in blocking-
mode where the PID is not available. (-1 was already taken to signify an
execution failure).

OS::execute will now properly return a non-OK error code when it fails
to execute the target file.

The documentation was rewritten to be very clear about the differences
between blocking and non-blocking mode.

Fixes #19056.

(cherry picked from commit f392650be2)
This commit is contained in:
Rémi Verschelde
2018-05-30 12:18:01 +02:00
parent d73de3fb97
commit 80e66a6214
3 changed files with 18 additions and 16 deletions

View File

@@ -375,7 +375,7 @@ Error _OS::shell_open(String p_uri) {
int _OS::execute(const String &p_path, const Vector<String> &p_arguments, bool p_blocking, Array p_output) {
OS::ProcessID pid;
OS::ProcessID pid = -2;
List<String> args;
for (int i = 0; i < p_arguments.size(); i++)
args.push_back(p_arguments[i]);
@@ -388,6 +388,7 @@ int _OS::execute(const String &p_path, const Vector<String> &p_arguments, bool p
else
return pid;
}
Error _OS::kill(int p_pid) {
return OS::get_singleton()->kill(p_pid);