fix(command): Use execlp()

Ref #214
This commit is contained in:
Michael Carlberg
2016-12-03 20:52:42 +01:00
parent bb0cfcf033
commit 5f6d73a415
6 changed files with 15 additions and 33 deletions

View File

@ -11,7 +11,7 @@
POLYBAR_NS
namespace command_util {
command::command(const logger& logger, string cmd) : m_log(logger), m_cmd("/usr/bin/env\nsh\n-c\n" + cmd) {
command::command(const logger& logger, string cmd) : m_log(logger), m_cmd(cmd) {
if (pipe(m_stdin) != 0) {
throw command_strerror("Failed to allocate input stream");
}
@ -76,9 +76,7 @@ namespace command_util {
process_util::unblock_signal(SIGTERM);
setpgid(m_forkpid, 0);
process_util::exec(m_cmd);
throw command_error("Exec failed");
process_util::exec_sh(m_cmd.c_str());
} else {
// Close file descriptors that won't be used by the parent
if ((m_stdin[PIPE_READ] = close(m_stdin[PIPE_READ])) == -1) {
@ -155,8 +153,8 @@ namespace command_util {
* @note: This is a blocking call and will not
* end until the stream is closed
*/
void command::tail(callback<string> callback) {
io_util::tail(m_stdout[PIPE_READ], move(callback));
void command::tail(callback<string> cb) {
io_util::tail(m_stdout[PIPE_READ], move(cb));
}
/**