diff options
author | Reid Kleckner <reid@kleckner.net> | 2013-06-13 15:27:17 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2013-06-13 15:27:17 +0000 |
commit | 62d124a1fa8b212bae1d331f027c9eec06a45199 (patch) | |
tree | d54ab55c93830ef075514d681167fd86d9fd81e9 /lib/Support/Program.cpp | |
parent | 0db5f0f07e6411fa25aefd464648ec8fc335a2d7 (diff) | |
download | llvm-62d124a1fa8b212bae1d331f027c9eec06a45199.tar.gz llvm-62d124a1fa8b212bae1d331f027c9eec06a45199.tar.bz2 llvm-62d124a1fa8b212bae1d331f027c9eec06a45199.tar.xz |
[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183906 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Program.cpp')
-rw-r--r-- | lib/Support/Program.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/Support/Program.cpp b/lib/Support/Program.cpp index 6e04a1cd53..b1a9b98755 100644 --- a/lib/Support/Program.cpp +++ b/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. |