aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/Program.cpp
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2013-06-13 15:27:17 +0000
committerReid Kleckner <reid@kleckner.net>2013-06-13 15:27:17 +0000
commit6e6a0f50b3314b1d0e6e8706959bd29b57ecd5be (patch)
tree72b9b1d2347c870b42baf1f70f17eaf447c56834 /llvm/lib/Support/Program.cpp
parent92509c1c0c8c9b3ad17aa265c2426a69ff0d0997 (diff)
downloadllvm-6e6a0f50b3314b1d0e6e8706959bd29b57ecd5be.zip
llvm-6e6a0f50b3314b1d0e6e8706959bd29b57ecd5be.tar.gz
llvm-6e6a0f50b3314b1d0e6e8706959bd29b57ecd5be.tar.bz2
[Support] Fix handle and memory leak for processes that are not waited for
Execute's Data parameter is now optional, so we won't allocate memory for it on Windows and we'll close the process handle. The Unix code should probably do something similar to avoid accumulation of zombie children that haven't been waited on. Tested on Linux and Windows. llvm-svn: 183906
Diffstat (limited to 'llvm/lib/Support/Program.cpp')
-rw-r--r--llvm/lib/Support/Program.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/lib/Support/Program.cpp b/llvm/lib/Support/Program.cpp
index 6e04a1c..b1a9b98 100644
--- a/llvm/lib/Support/Program.cpp
+++ b/llvm/lib/Support/Program.cpp
@@ -22,7 +22,7 @@ using namespace sys;
//=== independent code.
//===----------------------------------------------------------------------===//
-static bool Execute(void *&Data, const Path &path, const char **args,
+static bool Execute(void **Data, const Path &path, const char **args,
const char **env, const sys::Path **redirects,
unsigned memoryLimit, std::string *ErrMsg);
@@ -34,7 +34,7 @@ int sys::ExecuteAndWait(const Path &path, const char **args, const char **envp,
unsigned memoryLimit, std::string *ErrMsg,
bool *ExecutionFailed) {
void *Data = 0;
- if (Execute(Data, path, args, envp, redirects, memoryLimit, ErrMsg)) {
+ if (Execute(&Data, path, args, envp, redirects, memoryLimit, ErrMsg)) {
if (ExecutionFailed) *ExecutionFailed = false;
return Wait(Data, path, secondsToWait, ErrMsg);
}
@@ -45,8 +45,7 @@ int sys::ExecuteAndWait(const Path &path, const char **args, const char **envp,
void sys::ExecuteNoWait(const Path &path, const char **args, const char **envp,
const Path **redirects, unsigned memoryLimit,
std::string *ErrMsg) {
- void *Data = 0;
- Execute(Data, path, args, envp, redirects, memoryLimit, ErrMsg);
+ Execute(/*Data*/ 0, path, args, envp, redirects, memoryLimit, ErrMsg);
}
// Include the platform-specific parts of this class.