summaryrefslogtreecommitdiff
path: root/lib/System/Unix/Program.inc
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
commitedf8e48c216a10d1b867aba0308842116f83547b (patch)
tree68ea2eb029b6c4399cefff9e8ba5d1fc5ec21575 /lib/System/Unix/Program.inc
parenta607202a68085cee4d18894392be647d6cd4a53e (diff)
downloadllvm-edf8e48c216a10d1b867aba0308842116f83547b.tar.gz
llvm-edf8e48c216a10d1b867aba0308842116f83547b.tar.bz2
llvm-edf8e48c216a10d1b867aba0308842116f83547b.tar.xz
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/Unix/Program.inc')
-rw-r--r--lib/System/Unix/Program.inc17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/System/Unix/Program.inc b/lib/System/Unix/Program.inc
index fdd0c25fd1..ce757105f8 100644
--- a/lib/System/Unix/Program.inc
+++ b/lib/System/Unix/Program.inc
@@ -34,10 +34,14 @@
namespace llvm {
using namespace sys;
-Program::Program() : Pid_(0) {}
+Program::Program() : Data_(0) {}
Program::~Program() {}
+unsigned Program::GetPid() {
+ return reinterpret_cast<unsigned>(Data_);
+}
+
// This function just uses the PATH environment variable to find the program.
Path
Program::FindProgramByName(const std::string& progName) {
@@ -209,7 +213,7 @@ Program::Execute(const Path& path,
break;
}
- Pid_ = child;
+ Data_ = reinterpret_cast<void*>(child);
return true;
}
@@ -221,7 +225,7 @@ Program::Wait(unsigned secondsToWait,
#ifdef HAVE_SYS_WAIT_H
struct sigaction Act, Old;
- if (Pid_ == 0) {
+ if (Data_ == 0) {
MakeErrMsg(ErrMsg, "Process not started!");
return -1;
}
@@ -237,7 +241,7 @@ Program::Wait(unsigned secondsToWait,
// Parent process: Wait for the child process to terminate.
int status;
- int child = this->Pid_;
+ pid_t child = reinterpret_cast<pid_t>(Data_);
while (wait(&status) != child)
if (secondsToWait && errno == EINTR) {
// Kill the child.
@@ -285,12 +289,13 @@ Program::Wait(unsigned secondsToWait,
bool
Program::Kill(std::string* ErrMsg) {
- if (Pid_ == 0) {
+ if (Data_ == 0) {
MakeErrMsg(ErrMsg, "Process not started!");
return true;
}
- return (kill(Pid_, SIGKILL) == 0);
+ pid_t pid = reinterpret_cast<pid_t>(Data_);
+ return (kill(pid, SIGKILL) == 0);
}
bool Program::ChangeStdinToBinary(){