aboutsummaryrefslogtreecommitdiffstats
path: root/lib/System/Win32
diff options
context:
space:
mode:
authorMikhail Glushenkov <foldr@codedgers.com>2009-09-22 15:40:32 +0000
committerMikhail Glushenkov <foldr@codedgers.com>2009-09-22 15:40:32 +0000
commited6353b87ccbbf7ddaa63a25bfad14afc3079da0 (patch)
tree64ab1125fab46d2925f659c7e72133c8c3f00685 /lib/System/Win32
parentc2d3000deec82fd0c808af98c089e5eb628ef47b (diff)
downloadexternal_llvm-ed6353b87ccbbf7ddaa63a25bfad14afc3079da0.zip
external_llvm-ed6353b87ccbbf7ddaa63a25bfad14afc3079da0.tar.gz
external_llvm-ed6353b87ccbbf7ddaa63a25bfad14afc3079da0.tar.bz2
Remove the GetProcessId() call from Win32/Program.inc, take 2.
GetProcessId() was introduced only in Windows XP, and we want to support earlier versions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82548 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Win32')
-rw-r--r--lib/System/Win32/Program.inc32
1 files changed, 23 insertions, 9 deletions
diff --git a/lib/System/Win32/Program.inc b/lib/System/Win32/Program.inc
index af6cce6..a69826f 100644
--- a/lib/System/Win32/Program.inc
+++ b/lib/System/Win32/Program.inc
@@ -22,6 +22,13 @@
//=== and must not be UNIX code
//===----------------------------------------------------------------------===//
+namespace {
+ struct Win32ProcessInfo {
+ HANDLE hProcess;
+ DWORD dwProcessId;
+ };
+}
+
namespace llvm {
using namespace sys;
@@ -29,15 +36,16 @@ Program::Program() : Data_(0) {}
Program::~Program() {
if (Data_) {
- HANDLE hProcess = reinterpret_cast<HANDLE>(Data_);
- CloseHandle(hProcess);
+ Win32ProcessInfo* wpi = reinterpret_cast<Win32ProcessInfo*>(Data_);
+ CloseHandle(wpi->hProcess);
+ delete wpi;
Data_ = 0;
}
}
unsigned Program::GetPid() const {
- HANDLE hProcess = reinterpret_cast<HANDLE>(Data_);
- return GetProcessId(hProcess);
+ Win32ProcessInfo* wpi = reinterpret_cast<Win32ProcessInfo*>(Data_);
+ return wpi->dwProcessId;
}
// This function just uses the PATH environment variable to find the program.
@@ -138,8 +146,9 @@ Program::Execute(const Path& path,
unsigned memoryLimit,
std::string* ErrMsg) {
if (Data_) {
- HANDLE hProcess = reinterpret_cast<HANDLE>(Data_);
- CloseHandle(Data_);
+ Win32ProcessInfo* wpi = reinterpret_cast<Win32ProcessInfo*>(Data_);
+ CloseHandle(wpi->hProcess);
+ delete wpi;
Data_ = 0;
}
@@ -269,7 +278,10 @@ Program::Execute(const Path& path,
path.str() + "'");
return false;
}
- Data_ = reinterpret_cast<void*>(pi.hProcess);
+ Win32ProcessInfo* wpi = new Win32ProcessInfo;
+ wpi->hProcess = pi.hProcess;
+ wpi->dwProcessId = pi.dwProcessId;
+ Data_ = wpi;
// Make sure these get closed no matter what.
AutoHandle hThread(pi.hThread);
@@ -310,7 +322,8 @@ Program::Wait(unsigned secondsToWait,
return -1;
}
- HANDLE hProcess = reinterpret_cast<HANDLE>(Data_);
+ Win32ProcessInfo* wpi = reinterpret_cast<Win32ProcessInfo*>(Data_);
+ HANDLE hProcess = wpi->hProcess;
// Wait for the process to terminate.
DWORD millisecondsToWait = INFINITE;
@@ -346,7 +359,8 @@ Program::Kill(std::string* ErrMsg) {
return true;
}
- HANDLE hProcess = reinterpret_cast<HANDLE>(Data_);
+ Win32ProcessInfo* wpi = reinterpret_cast<Win32ProcessInfo*>(Data_);
+ HANDLE hProcess = wpi->hProcess;
if (TerminateProcess(hProcess, 1) == 0) {
MakeErrMsg(ErrMsg, "The process couldn't be killed!");
return true;