summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2009-10-04 18:18:32 +0000
committerChristian Pointner <equinox@anytun.org>2009-10-04 18:18:32 +0000
commitb33b8131fd85fe7cf54934500e421d96efcd801b (patch)
tree1794b9fc72c6003549d095337a8812dfa9533382
parentlogtargets valgrind cleanup (diff)
cleaned new exec script function
-rw-r--r--src/sysExec.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/sysExec.cpp b/src/sysExec.cpp
index ca62dfd..104581e 100644
--- a/src/sysExec.cpp
+++ b/src/sysExec.cpp
@@ -107,19 +107,14 @@ void anytun_exec(std::string const& script, StringVector const& args, StringList
argv[args.size() + 1] = NULL;
char** evp;
- if(env.size()) {
- evp = new char*[env.size() + 1];
- unsigned int i = 0;
- for(StringList::const_iterator it = env.begin(); it != env.end(); ++it) {
- evp[i] = new char[it->size() + 1];
- std::strcpy(evp[i], it->c_str());
- ++i;
- }
- evp[env.size()] = NULL;
- } else {
- evp = new char*[1];
- evp[0] = NULL;
+ evp = new char*[env.size() + 1];
+ unsigned int i = 0;
+ for(StringList::const_iterator it = env.begin(); it != env.end(); ++it) {
+ evp[i] = new char[it->size() + 1];
+ std::strcpy(evp[i], it->c_str());
+ ++i;
}
+ evp[env.size()] = NULL;
execve(script.c_str(), argv, evp);
// if execve returns, an error occurred, but logging doesn't work