Skip to content
Snippets Groups Projects
Commit 747cd67f authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #13587: daemon: don't overwrite argv[0]

This breaks various system tools' (i.e. pidof, netstat) ability to correctly identify the sflphoned
process
parent eb973433
Branches
Tags
No related merge requests found
......@@ -137,7 +137,14 @@ int main(int argc, char *argv [])
signal(SIGHUP, signal_handler);
signal(SIGTERM, signal_handler);
fileutils::set_program_dir(argv[0]);
// make a copy as we don't want to modify argv[0], copy it to a vector to
// guarantee that memory is correctly managed/exception safe
std::string programName(argv[0]);
std::vector<char> writable(programName.size() + 1);
std::copy(programName.begin(), programName.end(), writable.begin());
fileutils::set_program_dir(&*writable.begin());
print_title();
if (parse_args(argc, argv))
return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment