mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-27 14:34:58 +00:00
For PR351:
Implement the new environment pointer for ExecuteAndWait git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18928 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
44f6966ef0
commit
e2e2411f40
@ -79,7 +79,8 @@ Program::FindProgramByName(const std::string& progName) {
|
||||
//
|
||||
int
|
||||
Program::ExecuteAndWait(const Path& path,
|
||||
const std::vector<std::string>& args) {
|
||||
const std::vector<std::string>& args,
|
||||
const char ** envp ) {
|
||||
if (!path.executable())
|
||||
throw path.toString() + " is not executable";
|
||||
|
||||
@ -103,11 +104,15 @@ Program::ExecuteAndWait(const Path& path,
|
||||
break;
|
||||
|
||||
// Child process: Execute the program.
|
||||
case 0:
|
||||
execve (path.c_str(), (char** const)argv, environ);
|
||||
case 0: {
|
||||
char** env = environ;
|
||||
if (envp != 0)
|
||||
env = (char**) envp;
|
||||
execve (path.c_str(), (char** const)argv, env);
|
||||
// If the execve() failed, we should exit and let the parent pick up
|
||||
// our non-zero exit status.
|
||||
exit (errno);
|
||||
}
|
||||
|
||||
// Parent process: Break out of the switch to do our processing.
|
||||
default:
|
||||
|
@ -79,7 +79,8 @@ Program::FindProgramByName(const std::string& progName) {
|
||||
//
|
||||
int
|
||||
Program::ExecuteAndWait(const Path& path,
|
||||
const std::vector<std::string>& args) {
|
||||
const std::vector<std::string>& args,
|
||||
const char ** envp ) {
|
||||
if (!path.executable())
|
||||
throw path.toString() + " is not executable";
|
||||
|
||||
@ -103,11 +104,15 @@ Program::ExecuteAndWait(const Path& path,
|
||||
break;
|
||||
|
||||
// Child process: Execute the program.
|
||||
case 0:
|
||||
execve (path.c_str(), (char** const)argv, environ);
|
||||
case 0: {
|
||||
char** env = environ;
|
||||
if (envp != 0)
|
||||
env = (char**) envp;
|
||||
execve (path.c_str(), (char** const)argv, env);
|
||||
// If the execve() failed, we should exit and let the parent pick up
|
||||
// our non-zero exit status.
|
||||
exit (errno);
|
||||
}
|
||||
|
||||
// Parent process: Break out of the switch to do our processing.
|
||||
default:
|
||||
|
@ -69,7 +69,8 @@ Program::FindProgramByName(const std::string& progName) {
|
||||
//
|
||||
int
|
||||
Program::ExecuteAndWait(const Path& path,
|
||||
const std::vector<std::string>& args) {
|
||||
const std::vector<std::string>& args,
|
||||
const char** env) {
|
||||
if (!path.executable())
|
||||
throw path.toString() + " is not executable";
|
||||
|
||||
@ -124,8 +125,9 @@ Program::ExecuteAndWait(const Path& path,
|
||||
PROCESS_INFORMATION pi;
|
||||
memset(&pi, 0, sizeof(pi));
|
||||
|
||||
LPVOID lpEnvironment = envp;
|
||||
if (!CreateProcess(path.c_str(), command, NULL, NULL, FALSE, 0,
|
||||
NULL, NULL, &si, &pi))
|
||||
lpEnvironment, NULL, &si, &pi))
|
||||
{
|
||||
ThrowError(std::string("Couldn't execute program '") +
|
||||
path.toString() + "'");
|
||||
|
@ -69,7 +69,8 @@ Program::FindProgramByName(const std::string& progName) {
|
||||
//
|
||||
int
|
||||
Program::ExecuteAndWait(const Path& path,
|
||||
const std::vector<std::string>& args) {
|
||||
const std::vector<std::string>& args,
|
||||
const char** env) {
|
||||
if (!path.executable())
|
||||
throw path.toString() + " is not executable";
|
||||
|
||||
@ -124,8 +125,9 @@ Program::ExecuteAndWait(const Path& path,
|
||||
PROCESS_INFORMATION pi;
|
||||
memset(&pi, 0, sizeof(pi));
|
||||
|
||||
LPVOID lpEnvironment = envp;
|
||||
if (!CreateProcess(path.c_str(), command, NULL, NULL, FALSE, 0,
|
||||
NULL, NULL, &si, &pi))
|
||||
lpEnvironment, NULL, &si, &pi))
|
||||
{
|
||||
ThrowError(std::string("Couldn't execute program '") +
|
||||
path.toString() + "'");
|
||||
|
Loading…
x
Reference in New Issue
Block a user