mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-15 05:24:01 +00:00
[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
This commit is contained in:
@ -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.
|
||||
|
Reference in New Issue
Block a user