Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions apps/ll-init/src/ll-init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ std::vector<const char *> parse_args(int argc, char *argv[]) noexcept
while (idx < argc) {
args.emplace_back(argv[idx++]);
}
args.emplace_back(nullptr);

return args;
}
Expand All @@ -259,7 +258,7 @@ void print_child_status(int status, const std::string &pid) noexcept
}
}

pid_t run(std::vector<const char *> args, const sigConf &conf) noexcept
pid_t run(const std::vector<const char *> &args, const sigConf &conf) noexcept
{
auto pid = ::fork();
if (pid == -1) {
Comment thread
enkilee marked this conversation as resolved.
Expand All @@ -284,7 +283,15 @@ pid_t run(std::vector<const char *> args, const sigConf &conf) noexcept
return -1;
}

::execvp(args[0], const_cast<char *const *>(args.data()));
// build a null-terminated array for execvp
std::vector<char *> c_args;
c_args.reserve(args.size() + 1);
for (const auto *arg : args) {
c_args.emplace_back(const_cast<char *>(arg));
}
c_args.emplace_back(nullptr);

::execvp(c_args[0], c_args.data());
Comment thread
enkilee marked this conversation as resolved.
Outdated
print_sys_error("Failed to run process");
::_exit(EXIT_FAILURE);
}
Expand Down
Loading