mirror of
https://github.com/etlegacy/Update-Installer.git
synced 2024-11-23 04:01:59 +00:00
Implement ProcessUtils::waitForProcess() using code from Qt updater
Also fix a typo in UpdateInstaller::run()
This commit is contained in:
parent
e8e25e7c1c
commit
e3cec64375
2 changed files with 36 additions and 4 deletions
|
@ -1,6 +1,16 @@
|
|||
#include "ProcessUtils.h"
|
||||
|
||||
#include "Platform.h"
|
||||
#include "StringUtils.h"
|
||||
#include "Log.h"
|
||||
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#include <sys/wait.h>
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
void ProcessUtils::runAsync(const std::string& executable,
|
||||
const std::list<std::string>& args)
|
||||
|
@ -27,8 +37,30 @@ void ProcessUtils::runElevated(const std::string& executable,
|
|||
bool ProcessUtils::waitForProcess(long long pid)
|
||||
{
|
||||
#ifdef PLATFORM_UNIX
|
||||
// TODO
|
||||
pid_t result = ::waitpid(static_cast<pid_t>(pid), 0, 0);
|
||||
if (result < 0)
|
||||
{
|
||||
LOG(Error,"waitpid() failed with error" + intToStr(errno));
|
||||
}
|
||||
return result > 0;
|
||||
#elif defined(PLATFORM_WINDOWS)
|
||||
HANDLE hProc;
|
||||
|
||||
if (!(hProc = OpenProcess(SYNCHRONIZE, FALSE, static_cast<DWORD>(pid))))
|
||||
{
|
||||
LOG(Error,"Unable to get process handle for pid" + intToStr(pid) + "last error" + intToStr(GetLastError()));
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD dwRet = WaitForSingleObject(hProc, INFINITE);
|
||||
CloseHandle(hProc);
|
||||
|
||||
if (dwRet == WAIT_FAILED)
|
||||
{
|
||||
debug_logger(m_debugLog) << "WaitForSingleObject failed with error" << GetLastError();
|
||||
}
|
||||
|
||||
return (dwRet == WAIT_OBJECT_0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -37,13 +37,13 @@ void UpdateInstaller::run()
|
|||
{
|
||||
LOG(Info,"Starting update installation");
|
||||
|
||||
if (mode == Setup)
|
||||
if (m_mode == Setup)
|
||||
{
|
||||
}
|
||||
else if (mode == Main)
|
||||
else if (m_mode == Main)
|
||||
{
|
||||
}
|
||||
else if (mode == Cleanup)
|
||||
else if (m_mode == Cleanup)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue