fixed Process::isRunning() on Windows

This commit is contained in:
Günter Obiltschnig 2014-08-15 09:15:12 +02:00
parent d14be5730a
commit 5c04101a35
3 changed files with 16 additions and 29 deletions

View File

@ -260,23 +260,19 @@ bool ProcessImpl::isRunningImpl(const ProcessHandleImpl& handle)
{ {
bool result = true; bool result = true;
DWORD exitCode; DWORD exitCode;
BOOL rc = GetExitCodeProcess(handle.process(), &exitCode);
GetExitCodeProcess(handle.process(), &exitCode); if (!rc || exitCode != STILL_ACTIVE) result = false;
if (exitCode != STILL_ACTIVE) result = false;
return result; return result;
} }
bool ProcessImpl::isRunningImpl(PIDImpl pid) bool ProcessImpl::isRunningImpl(PIDImpl pid)
{ {
HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, pid); HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
bool result = true; bool result = true;
DWORD exitCode; DWORD exitCode;
BOOL rc = GetExitCodeProcess(hProc, &exitCode);
GetExitCodeProcess(hProc, &exitCode); if (!rc || exitCode != STILL_ACTIVE) result = false;
if (exitCode != STILL_ACTIVE) result = false;
return result; return result;
} }

View File

@ -266,23 +266,19 @@ bool ProcessImpl::isRunningImpl(const ProcessHandleImpl& handle)
{ {
bool result = true; bool result = true;
DWORD exitCode; DWORD exitCode;
BOOL rc = GetExitCodeProcess(handle.process(), &exitCode);
GetExitCodeProcess(handle.process(), &exitCode); if (!rc || exitCode != STILL_ACTIVE) result = false;
if (exitCode != STILL_ACTIVE) result = false;
return result; return result;
} }
bool ProcessImpl::isRunningImpl(PIDImpl pid) bool ProcessImpl::isRunningImpl(PIDImpl pid)
{ {
HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, pid); HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
bool result = true; bool result = true;
DWORD exitCode; DWORD exitCode;
BOOL rc = GetExitCodeProcess(hProc, &exitCode);
GetExitCodeProcess(hProc, &exitCode); if (!rc || exitCode != STILL_ACTIVE) result = false;
if (exitCode != STILL_ACTIVE) result = false;
return result; return result;
} }

View File

@ -191,25 +191,20 @@ bool ProcessImpl::isRunningImpl(const ProcessHandleImpl& handle)
{ {
bool result = true; bool result = true;
DWORD exitCode; DWORD exitCode;
BOOL rc = GetExitCodeProcess(handle.process(), &exitCode);
GetExitCodeProcess(handle.process(), &exitCode); if (!rc || exitCode != STILL_ACTIVE) result = false;
if (exitCode != STILL_ACTIVE) result = false;
return result; return result;
} }
bool ProcessImpl::isRunningImpl(PIDImpl pid) bool ProcessImpl::isRunningImpl(PIDImpl pid)
{ {
HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, pid); HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
bool result = true; bool result = true;
DWORD exitCode; DWORD exitCode;
BOOL rc = GetExitCodeProcess(hProc, &exitCode);
GetExitCodeProcess(hProc, &exitCode); if (!rc || exitCode != STILL_ACTIVE) result = false;
if (exitCode != STILL_ACTIVE) result = false; return result;}
return result;
}
void ProcessImpl::requestTerminationImpl(PIDImpl pid) void ProcessImpl::requestTerminationImpl(PIDImpl pid)