{
std::stringstream arg_buffer;
- for (size_t x= 0; x < argc; x++)
+ for (size_t x= 0; x < argc; ++x)
{
arg_buffer << built_argv[x] << " ";
}
{
std::stringstream arg_buffer;
- for (char** ptr= argv; *ptr; ptr++)
+ for (char** ptr= argv; *ptr; ++ptr)
{
arg_buffer << *ptr << " ";
}
posix_spawn_file_actions_t file_actions;
posix_spawn_file_actions_init(&file_actions);
- stdin_fd.dup_for_spawn(Application::Pipe::READ, file_actions);
- stdout_fd.dup_for_spawn(Application::Pipe::WRITE, file_actions);
- stderr_fd.dup_for_spawn(Application::Pipe::WRITE, file_actions);
+ stdin_fd.dup_for_spawn(file_actions);
+ stdout_fd.dup_for_spawn(file_actions);
+ stderr_fd.dup_for_spawn(file_actions);
posix_spawnattr_t spawnattr;
posix_spawnattr_init(&spawnattr);
data_was_read= true;
arg.reserve(read_length +1);
- for (size_t x= 0; x < read_length; x++)
+ for (size_t x= 0; x < read_length; ++x)
{
arg.push_back(buffer[x]);
}
Application::Pipe::~Pipe()
{
- close(READ);
- close(WRITE);
+ if (_pipe_fd[0] != -1)
+ {
+ ::close(_pipe_fd[0]);
+ }
+
+ if (_pipe_fd[1] != -1)
+ {
+ ::close(_pipe_fd[1]);
+ }
}
-void Application::Pipe::dup_for_spawn(const close_t& arg, posix_spawn_file_actions_t& file_actions)
+void Application::Pipe::dup_for_spawn(posix_spawn_file_actions_t& file_actions)
{
- int type= int(arg);
+ int type= STDIN_FILENO == _std_fd ? 0 : 1;
int ret;
if ((ret= posix_spawn_file_actions_adddup2(&file_actions, _pipe_fd[type], _std_fd )) < 0)
if (_open[type])
{
- int ret;
if (::close(_pipe_fd[type]) == -1)
{
Error << "close(" << strerror(errno) << ")";
_argc+= 1;
}
- for (Options::const_iterator iter= _options.begin(); iter != _options.end(); iter++)
+ for (Options::const_iterator iter= _options.begin(); iter != _options.end(); ++iter)
{
_argc++;
if ((*iter).second.empty() == false)
built_argv[x++]= strdup(_exectuble_with_path.c_str());
- for (Options::const_iterator iter= _options.begin(); iter != _options.end(); iter++)
+ for (Options::const_iterator iter= _options.begin(); iter != _options.end(); ++iter)
{
built_argv[x++]= strdup((*iter).first.c_str());
if ((*iter).second.empty() == false)
{
std::stringstream arg_buffer;
- for (size_t x= 1 + _use_libtool ? 2 : 0;
+ for (size_t x= (1 +_use_libtool) ? 2 : 0;
x < _argc and built_argv[x];
- x++)
+ ++x)
{
arg_buffer << built_argv[x] << " ";
}
{
if (built_argv)
{
- for (size_t x= 0; x < _argc; x++)
+ for (size_t x= 0; x < _argc; ++x)
{
if (built_argv[x])
{