$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r64076 - in sandbox/SOC/2010/process/boost/process: . detail
From: fotanus_at_[hidden]
Date: 2010-07-16 22:45:42
Author: fotanus
Date: 2010-07-16 22:45:40 EDT (Fri, 16 Jul 2010)
New Revision: 64076
URL: http://svn.boost.org/trac/boost/changeset/64076
Log:
POSIX: fixed posix capture streams.
Text files modified: 
   sandbox/SOC/2010/process/boost/process/detail/posix_helpers.hpp |     5 +++++                                   
   sandbox/SOC/2010/process/boost/process/operations.hpp           |    11 +++++++----                             
   sandbox/SOC/2010/process/boost/process/stream_behavior.hpp      |    29 ++++++++++++++---------------           
   3 files changed, 26 insertions(+), 19 deletions(-)
Modified: sandbox/SOC/2010/process/boost/process/detail/posix_helpers.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/detail/posix_helpers.hpp	(original)
+++ sandbox/SOC/2010/process/boost/process/detail/posix_helpers.hpp	2010-07-16 22:45:40 EDT (Fri, 16 Jul 2010)
@@ -99,4 +99,9 @@
 }
 }
 
+void posix_remap(int native_handle, int new_handle)
+{
+    if (::dup2(new_handle, native_handle) == -1)
+        BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("dup2() failed"); 
+}
 #endif
Modified: sandbox/SOC/2010/process/boost/process/operations.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/operations.hpp	(original)
+++ sandbox/SOC/2010/process/boost/process/operations.hpp	2010-07-16 22:45:40 EDT (Fri, 16 Jul 2010)
@@ -198,9 +198,6 @@
             for (int i = 0; i < maxdescs; ++i)
                 closeflags[i] = true;
 
-            // setup_input(infoin, closeflags.get(), maxdescs);
-            // setup_output(infoout, closeflags.get(), maxdescs);
-
             int stdin_fd = ctx.stdin_behavior->get_child_end();
             if (stdin_fd != -1 && stdin_fd < maxdescs)
                 closeflags[stdin_fd] = false;
@@ -219,7 +216,13 @@
                     ::close(i);
             }
 
-            // setup();
+            if(closeflags[stdin_fd] == false)
+                posix_remap(STDIN_FILENO, stdin_fd);
+            if(closeflags[stdout_fd] == false)
+                posix_remap(STDOUT_FILENO, stdout_fd);
+            if(closeflags[stderr_fd] == false)
+                posix_remap(STDERR_FILENO, stderr_fd);
+
         }
         catch (const boost::system::system_error &e)
         {
Modified: sandbox/SOC/2010/process/boost/process/stream_behavior.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/stream_behavior.hpp	(original)
+++ sandbox/SOC/2010/process/boost/process/stream_behavior.hpp	2010-07-16 22:45:40 EDT (Fri, 16 Jul 2010)
@@ -111,21 +111,21 @@
     inherit(native_type child_end) 
     : child_end_(child_end) 
     { 
-#if defined(BOOST_WINDOWS_API) 
-        if (!::DuplicateHandle(::GetCurrentProcess(), child_end_, ::GetCurrentProcess(), &child_end_, 0, TRUE, DUPLICATE_SAME_ACCESS)) 
-            BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("DuplicateHandle() failed"); 
-#endif 
-    } 
-
-    static boost::shared_ptr<inherit> def(native_type child_end) 
-    { 
-        return boost::make_shared<inherit>(inherit(child_end)); 
-    } 
+#if defined(BOOST_WINDOWS_API)
+        if (!::DuplicateHandle(::GetCurrentProcess(), child_end_, ::GetCurrentProcess(), &child_end_, 0, TRUE, DUPLICATE_SAME_ACCESS))
+            BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("DuplicateHandle() failed");
+#endif 
+    }
+
+    static boost::shared_ptr<inherit> def(native_type child_end)
+    {
+        return boost::make_shared<inherit>(inherit(child_end));
+    }
 
     native_type get_child_end() 
-    { 
-        return child_end_; 
-    } 
+    {
+        return child_end_;
+    }
 
 private: 
     native_type child_end_; 
@@ -142,9 +142,8 @@
 public: 
     enum stream_type { input_stream, output_stream }; 
 
-    pipe(stream_type stream) 
+    pipe(stream_type stream)
     { 
-		
         native_type natives[2]; 
 #if defined(BOOST_POSIX_API) 
         if (::pipe(natives) == -1)