Add OS::is_process_running function.
Adds the is_process_running function to the native OS class and exposes it to script.
This is implemented on Windows and Unix platforms. A stub is provided for other platforms that do not support this function.
Documentation is updated to reflect new API function.
(cherry picked from commit f3c1232c59)
This commit is contained in:
committed by
Rémi Verschelde
parent
cc12c69ea1
commit
53fb0440d3
@ -363,6 +363,15 @@ int OS_Unix::get_process_id() const {
|
||||
return getpid();
|
||||
};
|
||||
|
||||
bool OS_Unix::is_process_running(const ProcessID &p_pid) const {
|
||||
int status = 0;
|
||||
if (waitpid(p_pid, &status, WNOHANG) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OS_Unix::has_environment(const String &p_var) const {
|
||||
return getenv(p_var.utf8().get_data()) != nullptr;
|
||||
}
|
||||
|
||||
@ -87,6 +87,7 @@ public:
|
||||
virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking = true, ProcessID *r_child_id = nullptr, String *r_pipe = nullptr, int *r_exitcode = nullptr, bool read_stderr = false, Mutex *p_pipe_mutex = nullptr, bool p_open_console = false);
|
||||
virtual Error kill(const ProcessID &p_pid);
|
||||
virtual int get_process_id() const;
|
||||
virtual bool is_process_running(const ProcessID &p_pid) const;
|
||||
|
||||
virtual bool has_environment(const String &p_var) const;
|
||||
virtual String get_environment(const String &p_var) const;
|
||||
|
||||
Reference in New Issue
Block a user