summaryrefslogtreecommitdiff
path: root/platform/windows/os_windows.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-05-04 09:02:33 +0200
committerGitHub <noreply@github.com>2022-05-04 09:02:33 +0200
commit5022efef02cd671010438ca467e7e4411d177faa (patch)
tree11bab1eea284fe82ec6f2f76dbe31c866958e2c0 /platform/windows/os_windows.cpp
parented5e0499ff9b043e52086d6e29031b3ab9c9ca32 (diff)
parentf3c1232c5984a540c33841694469febbe951e7a8 (diff)
Merge pull request #51682 from mdavisprog/os-is-process-running
OS::is_process_running function.
Diffstat (limited to 'platform/windows/os_windows.cpp')
-rw-r--r--platform/windows/os_windows.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 6b4e455197..d43ab47004 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -517,6 +517,25 @@ int OS_Windows::get_process_id() const {
return _getpid();
}
+bool OS_Windows::is_process_running(const ProcessID &p_pid) const {
+ if (!process_map->has(p_pid)) {
+ return false;
+ }
+
+ const PROCESS_INFORMATION &pi = (*process_map)[p_pid].pi;
+
+ DWORD dw_exit_code = 0;
+ if (!GetExitCodeProcess(pi.hProcess, &dw_exit_code)) {
+ return false;
+ }
+
+ if (dw_exit_code != STILL_ACTIVE) {
+ return false;
+ }
+
+ return true;
+}
+
Error OS_Windows::set_cwd(const String &p_cwd) {
if (_wchdir((LPCWSTR)(p_cwd.utf16().get_data())) != 0) {
return ERR_CANT_OPEN;