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;
DWORD exitCode;
GetExitCodeProcess(handle.process(), &exitCode);
if (exitCode != STILL_ACTIVE) result = false;
BOOL rc = GetExitCodeProcess(handle.process(), &exitCode);
if (!rc || exitCode != STILL_ACTIVE) result = false;
return result;
}
bool ProcessImpl::isRunningImpl(PIDImpl pid)
{
HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
bool result = true;
DWORD exitCode;
GetExitCodeProcess(hProc, &exitCode);
if (exitCode != STILL_ACTIVE) result = false;
BOOL rc = GetExitCodeProcess(hProc, &exitCode);
if (!rc || exitCode != STILL_ACTIVE) result = false;
return result;
}

View File

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

View File

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