summaryrefslogtreecommitdiff
path: root/nix/libutil
diff options
context:
space:
mode:
Diffstat (limited to 'nix/libutil')
-rw-r--r--nix/libutil/util.cc11
-rw-r--r--nix/libutil/util.hh2
2 files changed, 6 insertions, 7 deletions
diff --git a/nix/libutil/util.cc b/nix/libutil/util.cc
index dab4235b04..14026ab829 100644
--- a/nix/libutil/util.cc
+++ b/nix/libutil/util.cc
@@ -897,10 +897,10 @@ pid_t startProcess(std::function<void()> fun,
}
-std::vector<const char *> stringsToCharPtrs(const Strings & ss)
+std::vector<char *> stringsToCharPtrs(const Strings & ss)
{
- std::vector<const char *> res;
- for (auto & s : ss) res.push_back(s.c_str());
+ std::vector<char *> res;
+ for (auto & s : ss) res.push_back((char *) s.c_str());
res.push_back(0);
return res;
}
@@ -921,12 +921,11 @@ string runProgram(Path program, bool searchPath, const Strings & args)
Strings args_(args);
args_.push_front(program);
- auto cargs = stringsToCharPtrs(args_);
if (searchPath)
- execvp(program.c_str(), (char * *) &cargs[0]);
+ execvp(program.c_str(), stringsToCharPtrs(args_).data());
else
- execv(program.c_str(), (char * *) &cargs[0]);
+ execv(program.c_str(), stringsToCharPtrs(args_).data());
throw SysError(format("executing `%1%'") % program);
});
diff --git a/nix/libutil/util.hh b/nix/libutil/util.hh
index 6a84ed8851..24e16ba36a 100644
--- a/nix/libutil/util.hh
+++ b/nix/libutil/util.hh
@@ -284,7 +284,7 @@ MakeError(ExecError, Error)
/* Convert a list of strings to a null-terminated vector of char
*'s. The result must not be accessed beyond the lifetime of the
list of strings. */
-std::vector<const char *> stringsToCharPtrs(const Strings & ss);
+std::vector<char *> stringsToCharPtrs(const Strings & ss);
/* Close all file descriptors except stdin, stdout, stderr, and those
listed in the given set. Good practice in child processes. */