//
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";
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:
//
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";
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:
//
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";
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() + "'");
//
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";
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() + "'");