diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2009-09-22 04:44:56 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2009-09-22 04:44:56 +0000 |
| commit | 7b446a001dafb355ef4915d7cdb36b8510ba4612 (patch) | |
| tree | af148fa71410a026fd20fff95fd913a849c1aa63 /llvm/lib/System/Unix | |
| parent | 24a0813fc47d56b26a2e13aee44a76fde09c7bd3 (diff) | |
| download | bcm5719-llvm-7b446a001dafb355ef4915d7cdb36b8510ba4612.tar.gz bcm5719-llvm-7b446a001dafb355ef4915d7cdb36b8510ba4612.zip | |
Revert "Get rid of GetProcessId in Win32/Program.inc.", this breaks
ExecuteAndWait.
llvm-svn: 82522
Diffstat (limited to 'llvm/lib/System/Unix')
| -rw-r--r-- | llvm/lib/System/Unix/Program.inc | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/llvm/lib/System/Unix/Program.inc b/llvm/lib/System/Unix/Program.inc index cf6876a54b1..56dea250a77 100644 --- a/llvm/lib/System/Unix/Program.inc +++ b/llvm/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; } |

