From f392650be2434aadad71af95a0b81a33900e84ec Mon Sep 17 00:00:00 2001 From: Rémi Verschelde Date: Wed, 30 May 2018 12:18:01 +0200 Subject: 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. --- core/bind/core_bind.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'core/bind/core_bind.cpp') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 14e380484..b7f20588f 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -399,7 +399,7 @@ Error _OS::shell_open(String p_uri) { int _OS::execute(const String &p_path, const Vector &p_arguments, bool p_blocking, Array p_output) { - OS::ProcessID pid; + OS::ProcessID pid = -2; List args; for (int i = 0; i < p_arguments.size(); i++) args.push_back(p_arguments[i]); @@ -412,6 +412,7 @@ int _OS::execute(const String &p_path, const Vector &p_arguments, bool p else return pid; } + Error _OS::kill(int p_pid) { return OS::get_singleton()->kill(p_pid); -- cgit v1.2.3-70-g09d2