aboutsummaryrefslogtreecommitdiffstats
path: root/lib/System/Win32
diff options
context:
space:
mode:
authorMikhail Glushenkov <foldr@codedgers.com>2009-09-08 19:50:55 +0000
committerMikhail Glushenkov <foldr@codedgers.com>2009-09-08 19:50:55 +0000
commit460b0175ff36930e7ab2a0c1e0ac1c861b704765 (patch)
tree68ea2eb029b6c4399cefff9e8ba5d1fc5ec21575 /lib/System/Win32
parenta28016831340436a42b077c2711e040c46cb106f (diff)
downloadexternal_llvm-460b0175ff36930e7ab2a0c1e0ac1c861b704765.zip
external_llvm-460b0175ff36930e7ab2a0c1e0ac1c861b704765.tar.gz
external_llvm-460b0175ff36930e7ab2a0c1e0ac1c861b704765.tar.bz2
Get rid of the Pid_ member in the Program class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81247 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Win32')
-rw-r--r--lib/System/Win32/Program.inc32
1 files changed, 18 insertions, 14 deletions
diff --git a/lib/System/Win32/Program.inc b/lib/System/Win32/Program.inc
index 4f4b6b3..b23fdce 100644
--- a/lib/System/Win32/Program.inc
+++ b/lib/System/Win32/Program.inc
@@ -25,16 +25,21 @@
namespace llvm {
using namespace sys;
-Program::Program() : Pid_(0), Data(0) {}
+Program::Program() : Data_(0) {}
Program::~Program() {
- if (Data) {
- HANDLE hProcess = (HANDLE) Data;
+ if (Data_) {
+ HANDLE hProcess = reinterpret_cast<HANDLE>(Data_);
CloseHandle(hProcess);
- Data = 0;
+ Data_ = 0;
}
}
+unsigned Program::GetPid() {
+ HANDLE hProcess = reinterpret_cast<HANDLE>(Data_);
+ return GetProcessId(hProcess);
+}
+
// This function just uses the PATH environment variable to find the program.
Path
Program::FindProgramByName(const std::string& progName) {
@@ -132,10 +137,10 @@ Program::Execute(const Path& path,
const Path** redirects,
unsigned memoryLimit,
std::string* ErrMsg) {
- if (Data) {
- HANDLE hProcess = (HANDLE) Data;
- CloseHandle(Data);
- Data = 0;
+ if (Data_) {
+ HANDLE hProcess = reinterpret_cast<HANDLE>(Data_);
+ CloseHandle(Data_);
+ Data_ = 0;
}
if (!path.canExecute()) {
@@ -264,8 +269,7 @@ Program::Execute(const Path& path,
path.str() + "'");
return false;
}
- Pid_ = pi.dwProcessId;
- Data = pi.hProcess;
+ Data_ = reinterpret_cast<void*>(pi.hProcess);
// Make sure these get closed no matter what.
AutoHandle hThread(pi.hThread);
@@ -301,12 +305,12 @@ Program::Execute(const Path& path,
int
Program::Wait(unsigned secondsToWait,
std::string* ErrMsg) {
- if (Data == 0) {
+ if (Data_ == 0) {
MakeErrMsg(ErrMsg, "Process not started!");
return -1;
}
- HANDLE hProcess = (HANDLE) Data;
+ HANDLE hProcess = reinterpret_cast<HANDLE>(Data_);
// Wait for the process to terminate.
DWORD millisecondsToWait = INFINITE;
@@ -337,12 +341,12 @@ Program::Wait(unsigned secondsToWait,
bool
Program::Kill(std::string* ErrMsg) {
- if (Data == 0) {
+ if (Data_ == 0) {
MakeErrMsg(ErrMsg, "Process not started!");
return true;
}
- HANDLE hProcess = reinterpret_cast<HANDLE>(Data);
+ HANDLE hProcess = reinterpret_cast<HANDLE>(Data_);
return TerminateProcess(hProcess, 1);
}