aboutsummaryrefslogtreecommitdiffstats
path: root/src/entropy
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-06-02 14:48:39 +0000
committerlloyd <[email protected]>2010-06-02 14:48:39 +0000
commitc717d76f72b7e0c90603f29cc537d0efbf6ce8a6 (patch)
tree1bfb3148fa6209f3932e0d242146d5b194881c94 /src/entropy
parentecaa781288897383fbce01df239f0129780a247a (diff)
Add constructor and destructor for pipe_wrapper to handle init and close
Diffstat (limited to 'src/entropy')
-rw-r--r--src/entropy/unix_procs/unix_cmd.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/entropy/unix_procs/unix_cmd.cpp b/src/entropy/unix_procs/unix_cmd.cpp
index 34e7c314a..c92c84b4c 100644
--- a/src/entropy/unix_procs/unix_cmd.cpp
+++ b/src/entropy/unix_procs/unix_cmd.cpp
@@ -37,6 +37,7 @@ void do_exec(const std::vector<std::string>& arg_list,
{
const std::string full_path = paths[j] + "/" + arg_list[0];
const char* fsname = full_path.c_str();
+
::execl(fsname, fsname, arg1, arg2, arg3, arg4, NULL);
}
}
@@ -50,7 +51,9 @@ struct pipe_wrapper
{
int fd;
pid_t pid;
- pipe_wrapper() { fd = -1; pid = 0; }
+
+ pipe_wrapper(int f, pid_t p) : fd(f), pid(p) {}
+ ~pipe_wrapper() { ::close(fd); }
};
/**
@@ -152,9 +155,7 @@ void DataSource_Command::create_pipe(const std::vector<std::string>& paths)
}
else if(pid > 0)
{
- pipe = new pipe_wrapper;
- pipe->fd = pipe_fd[0];
- pipe->pid = pid;
+ pipe = new pipe_wrapper(pipe_fd[0], pid);
::close(pipe_fd[1]);
}
else
@@ -200,7 +201,6 @@ void DataSource_Command::shutdown_pipe()
}
}
- ::close(pipe->fd);
delete pipe;
pipe = 0;
}