aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-22 16:04:46 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-22 16:04:46 +0100
commit710bda9da8c650dc63c5ceb5c1a161e75deff194 (patch)
treec11e12b2f3aa92ff3af34bfd2c7ea244064288cf
parent098b160b54af1f49f3b253281fa4ae243a67aa58 (diff)
downloadpaludis-710bda9da8c650dc63c5ceb5c1a161e75deff194.tar.gz
paludis-710bda9da8c650dc63c5ceb5c1a161e75deff194.tar.xz
Don't try to exit before we're done feeding
-rw-r--r--paludis/util/process.cc19
1 files changed, 15 insertions, 4 deletions
diff --git a/paludis/util/process.cc b/paludis/util/process.cc
index 1e22ec8..c61cb39 100644
--- a/paludis/util/process.cc
+++ b/paludis/util/process.cc
@@ -180,6 +180,8 @@ namespace paludis
std::unique_ptr<Pipe> pipe_command_handler_response_pipe;
std::string pipe_command_handler_buffer;
+ bool as_main_process;
+
/* must be last, so the thread gets join()ed before its FDs vanish */
std::unique_ptr<Thread> thread;
@@ -188,7 +190,8 @@ namespace paludis
capture_stdout(0),
capture_stderr(0),
capture_output_to_fd(0),
- send_input_to_fd(0)
+ send_input_to_fd(0),
+ as_main_process(false)
{
}
@@ -201,9 +204,12 @@ namespace paludis
void
RunningProcessThread::thread_func()
{
- bool prefix_stdout_buffer_has_newline(false), prefix_stderr_buffer_has_newline(false);
+ bool prefix_stdout_buffer_has_newline(false), prefix_stderr_buffer_has_newline(false), want_to_finish(true);
std::string input_stream_pending;
+ if (as_main_process && send_input_to_fd)
+ want_to_finish = false;
+
bool done(false);
while (! done)
{
@@ -212,8 +218,11 @@ RunningProcessThread::thread_func()
FD_ZERO(&read_fds);
FD_ZERO(&write_fds);
- FD_SET(ctl_pipe.read_fd(), &read_fds);
- max_fd = std::max(max_fd, ctl_pipe.read_fd());
+ if (want_to_finish)
+ {
+ FD_SET(ctl_pipe.read_fd(), &read_fds);
+ max_fd = std::max(max_fd, ctl_pipe.read_fd());
+ }
if (capture_stdout_pipe)
{
@@ -329,6 +338,7 @@ RunningProcessThread::thread_func()
throw ProcessError("close() send_input_to_fd_pipe write_fd failed");
send_input_to_fd_pipe->clear_write_fd();
send_input_to_fd = 0;
+ want_to_finish = true;
}
done_anything = true;
@@ -513,6 +523,7 @@ Process::run()
if (_imp->need_thread)
{
thread.reset(new RunningProcessThread{});
+ thread->as_main_process = _imp->as_main_process;
if (! _imp->prefix_stdout.empty())
{