aboutsummaryrefslogtreecommitdiff
path: root/lib/System/Unix/Program.inc
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-09-22 04:44:56 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-09-22 04:44:56 +0000
commit57d6903deae135ab39bf7d0e86ffae4029a938bd (patch)
tree98e897e8de0f2f6c8c1d2ef9c4041cb9a1362ef8 /lib/System/Unix/Program.inc
parent58c661ced16cd07c796bc867b1db0997c15db69f (diff)
Revert "Get rid of GetProcessId in Win32/Program.inc.", this breaks
ExecuteAndWait. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82522 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Unix/Program.inc')
-rw-r--r--lib/System/Unix/Program.inc23
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/System/Unix/Program.inc b/lib/System/Unix/Program.inc
index cf6876a54b..56dea250a7 100644
--- a/lib/System/Unix/Program.inc
+++ b/lib/System/Unix/Program.inc
@@ -34,6 +34,15 @@
namespace llvm {
using namespace sys;
+Program::Program() : Data_(0) {}
+
+Program::~Program() {}
+
+unsigned Program::GetPid() const {
+ uint64_t pid = reinterpret_cast<uint64_t>(Data_);
+ return static_cast<unsigned>(pid);
+}
+
// This function just uses the PATH environment variable to find the program.
Path
Program::FindProgramByName(const std::string& progName) {
@@ -205,7 +214,7 @@ Program::Execute(const Path& path,
break;
}
- Pid_ = child;
+ Data_ = reinterpret_cast<void*>(child);
return true;
}
@@ -217,7 +226,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;
}
@@ -233,7 +242,8 @@ Program::Wait(unsigned secondsToWait,
// Parent process: Wait for the child process to terminate.
int status;
- pid_t child = Pid_;
+ uint64_t pid = reinterpret_cast<uint64_t>(Data_);
+ pid_t child = static_cast<pid_t>(pid);
while (wait(&status) != child)
if (secondsToWait && errno == EINTR) {
// Kill the child.
@@ -281,12 +291,15 @@ Program::Wait(unsigned secondsToWait,
bool
Program::Kill(std::string* ErrMsg) {
- if (Pid_ == 0) {
+ if (Data_ == 0) {
MakeErrMsg(ErrMsg, "Process not started!");
return true;
}
- if (kill(Pid_, SIGKILL) != 0) {
+ uint64_t pid64 = reinterpret_cast<uint64_t>(Data_);
+ pid_t pid = static_cast<pid_t>(pid64);
+
+ if (kill(pid, SIGKILL) != 0) {
MakeErrMsg(ErrMsg, "The process couldn't be killed!");
return true;
}