Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64034 - in sandbox/SOC/2010/process: boost/process libs/process/example
From: fotanus_at_[hidden]
Date: 2010-07-14 22:08:02


Author: fotanus
Date: 2010-07-14 22:07:59 EDT (Wed, 14 Jul 2010)
New Revision: 64034
URL: http://svn.boost.org/trac/boost/changeset/64034

Log:
WIN32 update.

Restarted to track on matrix what is working and what is not.

*Pipes fixed
*Wait fixed
*Examples update

Added:
   sandbox/SOC/2010/process/libs/process/example/read_from_child.cpp
      - copied, changed from r62881, /sandbox/SOC/2010/process/libs/process/example/read_from_child.cpp
   sandbox/SOC/2010/process/libs/process/example/wait_child.cpp
      - copied, changed from r62881, /sandbox/SOC/2010/process/libs/process/example/wait_child.cpp
   sandbox/SOC/2010/process/libs/process/example/write_to_child.cpp
      - copied, changed from r62882, /sandbox/SOC/2010/process/libs/process/example/write_to_child.cpp
Text files modified:
   sandbox/SOC/2010/process/boost/process/process.hpp | 6 +++++-
   sandbox/SOC/2010/process/boost/process/status.hpp | 2 ++
   sandbox/SOC/2010/process/boost/process/stream_behavior.hpp | 4 +++-
   sandbox/SOC/2010/process/libs/process/example/read_from_child.cpp | 7 ++++++-
   sandbox/SOC/2010/process/libs/process/example/wait_child.cpp | 7 ++++---
   sandbox/SOC/2010/process/libs/process/example/write_to_child.cpp | 2 +-
   6 files changed, 21 insertions(+), 7 deletions(-)

Modified: sandbox/SOC/2010/process/boost/process/process.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/process.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/process.hpp 2010-07-14 22:07:59 EDT (Wed, 14 Jul 2010)
@@ -137,15 +137,19 @@
             BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("waitpid(2) failed");
         return s;
 #elif defined(BOOST_WINDOWS_API)
- HANDLE h = ::OpenProcess(SYNCHRONIZE, FALSE, id_);
+
+ HANDLE h = ::OpenProcess(PROCESS_QUERY_INFORMATION |SYNCHRONIZE , FALSE, id_);
         if (h == NULL)
             BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("OpenProcess() failed");
+
         if (::WaitForSingleObject(h, INFINITE) == WAIT_FAILED)
         {
             ::CloseHandle(h);
             BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("WaitForSingleObject() failed");
         }
+
         DWORD exit_code;
+
         if (!::GetExitCodeProcess(h, &exit_code))
         {
             ::CloseHandle(h);

Modified: sandbox/SOC/2010/process/boost/process/status.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/status.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/status.hpp 2010-07-14 22:07:59 EDT (Wed, 14 Jul 2010)
@@ -30,3 +30,5 @@
 
 }
 }
+
+#endif

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-14 22:07:59 EDT (Wed, 14 Jul 2010)
@@ -144,6 +144,7 @@
 
     pipe(stream_type stream)
     {
+
         native_type natives[2];
 #if defined(BOOST_POSIX_API)
         if (::pipe(natives) == -1)
@@ -153,7 +154,7 @@
         ZeroMemory(&sa, sizeof(sa));
         sa.nLength = sizeof(sa);
         sa.lpSecurityDescriptor = NULL;
- sa.bInheritHandle = TRUE;
+ //sa.bInheritHandle = TRUE;
         if (!::CreatePipe(&natives[0], &natives[1], &sa, 0))
             BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("CreatePipe() failed");
 #endif
@@ -163,6 +164,7 @@
         if (!::SetHandleInformation(child_end_, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT))
             BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("SetHandleInformation() failed");
 #endif
+
     }
 
     static boost::shared_ptr<pipe> def(stream_type stream)

Copied: sandbox/SOC/2010/process/libs/process/example/read_from_child.cpp (from r62881, /sandbox/SOC/2010/process/libs/process/example/read_from_child.cpp)
==============================================================================
--- /sandbox/SOC/2010/process/libs/process/example/read_from_child.cpp (original)
+++ sandbox/SOC/2010/process/libs/process/example/read_from_child.cpp 2010-07-14 22:07:59 EDT (Wed, 14 Jul 2010)
@@ -18,8 +18,13 @@
 
 int main()
 {
+
     std::string exe = find_executable_in_path("hostname");
- child c = create_child(exe);
+ context ctx;
+ ctx.stdout_behavior = behavior::pipe::def(behavior::pipe::stream_type::output_stream);
+
+ child c = create_child(exe,ctx);
     pistream &is = c.get_stdout();
     std::cout << is.rdbuf();
+ c.wait();
 }

Copied: sandbox/SOC/2010/process/libs/process/example/wait_child.cpp (from r62881, /sandbox/SOC/2010/process/libs/process/example/wait_child.cpp)
==============================================================================
--- /sandbox/SOC/2010/process/libs/process/example/wait_child.cpp (original)
+++ sandbox/SOC/2010/process/libs/process/example/wait_child.cpp 2010-07-14 22:07:59 EDT (Wed, 14 Jul 2010)
@@ -20,7 +20,8 @@
 {
     std::string exe = find_executable_in_path("hostname");
     child c = create_child(exe);
- status s = c.wait();
- if (s.exited())
- std::cout << s.exit_code() << std::endl;
+
+ int exit_c = c.wait();
+ std::cout << exit_c << std::endl;
+
 }

Copied: sandbox/SOC/2010/process/libs/process/example/write_to_child.cpp (from r62882, /sandbox/SOC/2010/process/libs/process/example/write_to_child.cpp)
==============================================================================
--- /sandbox/SOC/2010/process/libs/process/example/write_to_child.cpp (original)
+++ sandbox/SOC/2010/process/libs/process/example/write_to_child.cpp 2010-07-14 22:07:59 EDT (Wed, 14 Jul 2010)
@@ -20,7 +20,7 @@
 {
     std::string exe = find_executable_in_path("ftp");
     context ctx;
- ctx.stdin_behavior = boost::make_shared<capture>(capture(capture::input_stream));
+ ctx.stdin_behavior = behavior::pipe::def(behavior::pipe::stream_type::input_stream);
     child c = create_child(exe, ctx);
     postream &os = c.get_stdin();
     os << "quit" << std::endl;


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