Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r66394 - sandbox/SOC/2010/process/boost/process/detail
From: boris_at_[hidden]
Date: 2010-11-03 20:13:45


Author: bschaeling
Date: 2010-11-03 20:13:35 EDT (Wed, 03 Nov 2010)
New Revision: 66394
URL: http://svn.boost.org/trac/boost/changeset/66394

Log:
Fixed a bug when a process waits synchronously and asynchronously for two child processes on a POSIX system
Text files modified:
   sandbox/SOC/2010/process/boost/process/detail/basic_status_service.hpp | 28 +++++++++++++++++++++++++++-
   1 files changed, 27 insertions(+), 1 deletions(-)

Modified: sandbox/SOC/2010/process/boost/process/detail/basic_status_service.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/detail/basic_status_service.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/detail/basic_status_service.hpp 2010-11-03 20:13:35 EDT (Wed, 03 Nov 2010)
@@ -41,6 +41,7 @@
 #include <boost/make_shared.hpp>
 #include <boost/scoped_ptr.hpp>
 #include <boost/system/error_code.hpp>
+#include <boost/unordered_map.hpp>
 #include <vector>
 #include <algorithm>
 
@@ -122,6 +123,24 @@
     {
         boost::system::error_code ec;
         int status = impl->wait(pid, ec);
+#if defined(BOOST_POSIX_API)
+ if (ec.value() == ECHILD)
+ {
+ boost::unique_lock<boost::mutex> lock(work_thread_mutex_);
+ boost::unordered_map<pid_t, int>::iterator it = statuses_.find(pid);
+ if (it == statuses_.end())
+ {
+ work_thread_cond_.wait(work_thread_mutex_);
+ it = statuses_.find(pid);
+ }
+ if (it != statuses_.end())
+ {
+ status = it->second;
+ statuses_.erase(it);
+ ec.clear();
+ }
+ }
+#endif
         boost::asio::detail::throw_error(ec);
         return status;
     }
@@ -195,6 +214,12 @@
                     work_.reset();
                     break;
                 }
+ else if (!regchild)
+ {
+ statuses_.insert(boost::unordered_map<pid_t, int>::
+ value_type(pid, status));
+ work_thread_cond_.notify_all();
+ }
             }
         }
 #elif defined(BOOST_WINDOWS_API)
@@ -275,12 +300,13 @@
     std::vector<implementation_type> impls_;
     boost::mutex work_thread_mutex_;
     boost::thread work_thread_;
+ boost::condition_variable_any work_thread_cond_;
 #if defined(BOOST_POSIX_API)
     pid_t interrupt_pid_;
     int pids_;
+ boost::unordered_map<pid_t, int> statuses_;
 #elif defined(BOOST_WINDOWS_API)
     bool run_;
- boost::condition_variable_any work_thread_cond_;
     std::vector<HANDLE> handles_;
 #endif
 };


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk