diff --git a/udevmon.cpp b/udevmon.cpp index 70a28be..60fcbe2 100644 --- a/udevmon.cpp +++ b/udevmon.cpp @@ -101,7 +101,11 @@ struct cmd { for (size_t j = 0; j < cmds[i].size(); ++j) command[j] = const_cast(cmds[i][j].c_str()); command[cmds[i].size()] = nullptr; - char *environment[] = {nullptr}; + std::string path_env = "PATH="; + path_env += std::getenv("PATH"); + char *environment[] = { + const_cast(path_env.c_str()), + nullptr}; setpgid(0, 0); execvpe(command[0], command.get(), environment); std::string e = "exec failed for \""; @@ -348,7 +352,10 @@ struct job { command[j] = const_cast(cmds[i][j].c_str()); command[cmds[i].size()] = nullptr; std::string variables = "DEVNODE=" + devnode; + std::string path_env = "PATH="; + path_env += std::getenv("PATH"); char *environment[] = { + const_cast(path_env.c_str()), const_cast(variables.c_str()), nullptr}; setpgid(0, 0); execvpe(command[0], command.get(), environment);