1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-11 13:50:56 -05:00

Add env parameter in command::exec()

This commit is contained in:
TheDoctor314 2021-09-29 00:36:40 +05:30 committed by Patrick Ziegler
parent a7b978412c
commit 37cd63a356
2 changed files with 3 additions and 3 deletions

View file

@ -88,7 +88,7 @@ class command<output_policy::REDIRECTED> : private command<output_policy::IGNORE
command& operator=(const command&) = delete; command& operator=(const command&) = delete;
int exec(bool wait_for_completion = true); int exec(bool wait_for_completion = true, const vector<pair<string, string>>& env = {});
using command<output_policy::IGNORED>::terminate; using command<output_policy::IGNORED>::terminate;
using command<output_policy::IGNORED>::is_running; using command<output_policy::IGNORED>::is_running;
using command<output_policy::IGNORED>::wait; using command<output_policy::IGNORED>::wait;

View file

@ -128,7 +128,7 @@ command<output_policy::REDIRECTED>::~command() {
/** /**
* Execute the command * Execute the command
*/ */
int command<output_policy::REDIRECTED>::exec(bool wait_for_completion) { int command<output_policy::REDIRECTED>::exec(bool wait_for_completion, const vector<pair<string, string>>& env) {
if ((m_forkpid = fork()) == -1) { if ((m_forkpid = fork()) == -1) {
throw system_error("Failed to fork process"); throw system_error("Failed to fork process");
} }
@ -159,7 +159,7 @@ int command<output_policy::REDIRECTED>::exec(bool wait_for_completion) {
} }
setpgid(m_forkpid, 0); setpgid(m_forkpid, 0);
process_util::exec_sh(m_cmd.c_str()); process_util::exec_sh(m_cmd.c_str(), env);
} else { } else {
// Close file descriptors that won't be used by the parent // Close file descriptors that won't be used by the parent
if ((m_stdin[PIPE_READ] = close(m_stdin[PIPE_READ])) == -1) { if ((m_stdin[PIPE_READ] = close(m_stdin[PIPE_READ])) == -1) {