fix(process_util): Memory leak
This commit is contained in:
parent
b11a662d81
commit
16592ce514
@ -27,18 +27,23 @@ namespace process_util {
|
|||||||
* Execute command
|
* Execute command
|
||||||
*/
|
*/
|
||||||
void exec(char* cmd, char** args) {
|
void exec(char* cmd, char** args) {
|
||||||
|
if (cmd != nullptr) {
|
||||||
execvp(cmd, args);
|
execvp(cmd, args);
|
||||||
throw system_error("execvp() failed");
|
throw system_error("execvp() failed");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute command using shell
|
* Execute command using shell
|
||||||
*/
|
*/
|
||||||
void exec_sh(const char* cmd) {
|
void exec_sh(const char* cmd) {
|
||||||
static const char* shell = env_util::get("SHELL", "/bin/sh").c_str();
|
static const string shell{env_util::get("SHELL", "/bin/sh").c_str()};
|
||||||
execlp(shell, shell, "-c", cmd, nullptr);
|
|
||||||
|
if (cmd != nullptr) {
|
||||||
|
execlp(shell.c_str(), shell.c_str(), "-c", cmd, nullptr);
|
||||||
throw system_error("execvp() failed");
|
throw system_error("execvp() failed");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wait for child process
|
* Wait for child process
|
||||||
|
Loading…
Reference in New Issue
Block a user