aboutsummaryrefslogtreecommitdiffstats
path: root/lib/System/Unix
diff options
context:
space:
mode:
authorMikhail Glushenkov <foldr@codedgers.com>2009-09-15 03:39:45 +0000
committerMikhail Glushenkov <foldr@codedgers.com>2009-09-15 03:39:45 +0000
commit5083953c49cfb42b74a512d6b876340cdb958733 (patch)
treeacce5f7a1fd097c07638ff48bd12812c67ca321e /lib/System/Unix
parent4f21ba08e546e678bd6cc4c6efd66040507d8050 (diff)
downloadexternal_llvm-5083953c49cfb42b74a512d6b876340cdb958733.zip
external_llvm-5083953c49cfb42b74a512d6b876340cdb958733.tar.gz
external_llvm-5083953c49cfb42b74a512d6b876340cdb958733.tar.bz2
Get rid of GetProcessId in Win32/Program.inc.
GetProcessId was introduced only in XP. As a bonus, this change makes Program objects copyable, since Program is now basically a PID. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81826 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Unix')
-rw-r--r--lib/System/Unix/Program.inc23
1 files changed, 5 insertions, 18 deletions
diff --git a/lib/System/Unix/Program.inc b/lib/System/Unix/Program.inc
index 56dea25..cf6876a 100644
--- a/lib/System/Unix/Program.inc
+++ b/lib/System/Unix/Program.inc
@@ -34,15 +34,6 @@
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) {
@@ -214,7 +205,7 @@ Program::Execute(const Path& path,
break;
}
- Data_ = reinterpret_cast<void*>(child);
+ Pid_ = child;
return true;
}
@@ -226,7 +217,7 @@ Program::Wait(unsigned secondsToWait,
#ifdef HAVE_SYS_WAIT_H
struct sigaction Act, Old;
- if (Data_ == 0) {
+ if (Pid_ == 0) {
MakeErrMsg(ErrMsg, "Process not started!");
return -1;
}
@@ -242,8 +233,7 @@ Program::Wait(unsigned secondsToWait,
// Parent process: Wait for the child process to terminate.
int status;
- uint64_t pid = reinterpret_cast<uint64_t>(Data_);
- pid_t child = static_cast<pid_t>(pid);
+ pid_t child = Pid_;
while (wait(&status) != child)
if (secondsToWait && errno == EINTR) {
// Kill the child.
@@ -291,15 +281,12 @@ Program::Wait(unsigned secondsToWait,
bool
Program::Kill(std::string* ErrMsg) {
- if (Data_ == 0) {
+ if (Pid_ == 0) {
MakeErrMsg(ErrMsg, "Process not started!");
return true;
}
- uint64_t pid64 = reinterpret_cast<uint64_t>(Data_);
- pid_t pid = static_cast<pid_t>(pid64);
-
- if (kill(pid, SIGKILL) != 0) {
+ if (kill(Pid_, SIGKILL) != 0) {
MakeErrMsg(ErrMsg, "The process couldn't be killed!");
return true;
}