Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62484 - in sandbox/SOC/2010/process: boost boost/process boost/process/detail libs/process/example
From: boris_at_[hidden]
Date: 2010-06-06 10:21:57


Author: bschaeling
Date: 2010-06-06 10:21:55 EDT (Sun, 06 Jun 2010)
New Revision: 62484
URL: http://svn.boost.org/trac/boost/changeset/62484

Log:
Reviewed Boost.Process (tested building and running of create_process sample program with VC++ 2008 on Windows)
Text files modified:
   sandbox/SOC/2010/process/boost/process.hpp | 21 ++++++-----
   sandbox/SOC/2010/process/boost/process/child.hpp | 39 ++++++++++------------
   sandbox/SOC/2010/process/boost/process/config.hpp | 5 +-
   sandbox/SOC/2010/process/boost/process/context.hpp | 62 ++++++++++++++--------------------
   sandbox/SOC/2010/process/boost/process/detail/stream_detail.hpp | 6 +-
   sandbox/SOC/2010/process/boost/process/detail/win32_helpers.hpp | 4 +-
   sandbox/SOC/2010/process/boost/process/environment.hpp | 2
   sandbox/SOC/2010/process/boost/process/operations.hpp | 70 ++++++++++++++++++++++-----------------
   sandbox/SOC/2010/process/boost/process/process.hpp | 21 +++++++----
   sandbox/SOC/2010/process/boost/process/self.hpp | 39 ++++++++++++++--------
   sandbox/SOC/2010/process/boost/process/status.hpp | 16 +++++----
   sandbox/SOC/2010/process/boost/process/stream_behavior.hpp | 17 ++++-----
   sandbox/SOC/2010/process/libs/process/example/create_process.cpp | 10 +----
   13 files changed, 161 insertions(+), 151 deletions(-)

Modified: sandbox/SOC/2010/process/boost/process.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process.hpp (original)
+++ sandbox/SOC/2010/process/boost/process.hpp 2010-06-06 10:21:55 EDT (Sun, 06 Jun 2010)
@@ -1,13 +1,14 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
+//
+// Boost.Process
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2006, 2007 Julio M. Merino Vidal
+// Copyright (c) 2008, 2009 Boris Schaeling
+// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
 
 /**
  * \file boost/process.hpp

Modified: sandbox/SOC/2010/process/boost/process/child.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/child.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/child.hpp 2010-06-06 10:21:55 EDT (Sun, 06 Jun 2010)
@@ -22,9 +22,6 @@
 #include <boost/process/config.hpp>
 
 #if defined(BOOST_POSIX_API)
-# include <sys/types.h>
-# include <sys/wait.h>
-# include <cerrno>
 #elif defined(BOOST_WINDOWS_API)
 # include <windows.h>
 #else
@@ -35,11 +32,8 @@
 #include <boost/process/pistream.hpp>
 #include <boost/process/postream.hpp>
 #include <boost/process/detail/file_handle.hpp>
-#include <boost/system/system_error.hpp>
-#include <boost/throw_exception.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/assert.hpp>
-#include <iostream>
 #include <vector>
 
 namespace boost {
@@ -104,16 +98,12 @@
      * It is only used on Windows as the implementation of wait() needs a
      * process handle.
      */
- child(id_type id, detail::file_handle &fhstdin, detail::file_handle
- &fhstdout, detail::file_handle &fhstderr, detail::file_handle
- fhprocess = detail::file_handle())
+ child(id_type id, detail::file_handle &fhstdin, detail::file_handle &fhstdout, detail::file_handle &fhstderr, detail::file_handle fhprocess = detail::file_handle())
         : process(id)
+#if defined(BOOST_WINDOWS_API)
+ ,process_handle_(fhprocess.release(), ::CloseHandle)
+#endif
     {
-#if defined(BOOST_WINDOWS_API)
- process_handle_ = boost::shared_ptr<void>(fhprocess.release(),
- ::CloseHandle);
-#endif
- std::cout << "Criado com ID " << process_handle_.get() << std::endl;
         if (fhstdin.valid())
             stdin_.reset(new postream(fhstdin));
         if (fhstdout.valid())
@@ -153,15 +143,22 @@
      */
     boost::shared_ptr<pistream> stderr_;
 
- /**
- * Collection of child objects.
- *
- * This convenience type represents a collection of child objects backed
- * by a vector.
- */
- typedef std::vector<child> children;
+#if defined(BOOST_WINDOWS_API)
+ /**
+ * Process handle owned by RAII object.
+ */
+ boost::shared_ptr<void> process_handle_;
+#endif
 };
 
+/**
+ * Collection of child objects.
+ *
+ * This convenience type represents a collection of child objects backed
+ * by a vector.
+ */
+typedef std::vector<child> children;
+
 }
 }
 

Modified: sandbox/SOC/2010/process/boost/process/config.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/config.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/config.hpp 2010-06-06 10:21:55 EDT (Sun, 06 Jun 2010)
@@ -31,9 +31,8 @@
  * By default it is set to 259. You should set the macro to PATH_MAX
  * which should be defined in limits.h provided by your operating system
  * if you experience problems when instantiating a context. The
- * constructor of basic_work_directory_context tries to find out
- * dynamically the maximal supported path length but uses
- * BOOST_PROCESS_POSIX_PATH_MAX if it fails.
+ * constructor of context tries to find out the maximal supported path
+ * length but uses BOOST_PROCESS_POSIX_PATH_MAX if it fails.
  */
 # define BOOST_PROCESS_POSIX_PATH_MAX 259
 # endif

Modified: sandbox/SOC/2010/process/boost/process/context.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/context.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/context.hpp 2010-06-06 10:21:55 EDT (Sun, 06 Jun 2010)
@@ -13,64 +13,54 @@
 /**
  * \file boost/process/context.hpp
  *
- * Includes the declaration of the context struct.
- *
+ * Includes the declaration of the context class.
  */
 
-#include <boost/process/config.hpp>
+#ifndef BOOST_PROCESS_CONTEXT_HPP
+#define BOOST_PROCESS_CONTEXT_HPP
+
 #include <boost/process/stream_behavior.hpp>
 #include <boost/process/environment.hpp>
 #include <boost/process/self.hpp>
-#include <map>
-#include <string>
-
-#ifndef BOOST_PROCESS_CONTEXT_HPP
-#define BOOST_PROCESS_CONTEXT_HPP
 
 namespace boost {
 namespace process {
 
 /*
- * This is the declaration of context struct.
- *
- * The context struct defines a context for a processes
- * that will be created. It can defines the stream behaviors,
- * process name, the base directory for the process, and others.
- *
- * environment: It's a map from environment variables and it's values.
- * process_name: Define a name (argv[0]) of the process
- * io_service: TODO: Check when async is implemented
- * work_dir: The base dir for the new process.
- * stdin_behavior: Defines how the stdin of the process will be handled
- * stdout_behavior: Defines how the stdout of the process will be handled
- * stderr_behavior: ...
- *
+ * Context class that defines how a process is created.
  */
 struct context
 {
- environment_t environment;
- std::string process_name;
- std::string work_dir;
     stream_behavior stdin_behavior;
     stream_behavior stdout_behavior;
     stream_behavior stderr_behavior;
+ std::string process_name;
+ std::string work_dir;
+ environment_t environment;
 
- context()
+ /**
+ * Constructs a process context.
+ *
+ * Sets behavior of standard streams (inherit), current work directory
+ * and environment variables.
+ */
+ context()
+ : stdin_behavior(inherit),
+ stdout_behavior(inherit),
+ stderr_behavior(inherit),
+ work_dir(self::get_work_dir()),
+ environment(self::get_environment())
     {
- stdin_behavior = inherit;
- stdout_behavior = inherit;
- stderr_behavior = inherit;
- work_dir = self::get_work_dir();
- environment = self::get_environment();
     }
 };
 
-/*
- * This is the DEFALT_CONTEXT constant.
- * It represents a context with default values that will be
- * assign to a process if no context is passed by parameter.
+/**
+ * Default context object.
+ *
+ * The default context object is used when child processes are created
+ * without defining a context explicitly.
  */
-static struct context DEFAULT_CONTEXT;
+const context default_context;
 
 }
 }

Modified: sandbox/SOC/2010/process/boost/process/detail/stream_detail.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/detail/stream_detail.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/detail/stream_detail.hpp 2010-06-06 10:21:55 EDT (Sun, 06 Jun 2010)
@@ -18,6 +18,9 @@
  *
  */
 
+#ifndef BOOST_PROCESS_STREAM_DETAIL_HPP
+#define BOOST_PROCESS_STREAM_DETAIL_HPP
+
 #include <boost/process/config.hpp>
 #include <boost/process/stream_behavior.hpp>
 #include <boost/process/detail/file_handle.hpp>
@@ -25,9 +28,6 @@
 #include <boost/optional.hpp>
 #include <map>
 
-#ifndef BOOST_PROCESS_STREAM_DETAIL_HPP
-#define BOOST_PROCESS_STREAM_DETAIL_HPP
-
 namespace boost {
 namespace process {
 namespace detail {

Modified: sandbox/SOC/2010/process/boost/process/detail/win32_helpers.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/detail/win32_helpers.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/detail/win32_helpers.hpp 2010-06-06 10:21:55 EDT (Sun, 06 Jun 2010)
@@ -147,7 +147,7 @@
 
     switch (sd.behavior)
     {
- case closed:
+ case close:
     {
         return_handle = file_handle();
         break;
@@ -157,7 +157,7 @@
         return_handle = file_handle::win32_dup_std(sd.stream_handle, true);
         break;
     }
- case dummy:
+ case mute:
     {
         HANDLE h;
         if(sd.stream_type == stdin_type)

Modified: sandbox/SOC/2010/process/boost/process/environment.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/environment.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/environment.hpp 2010-06-06 10:21:55 EDT (Sun, 06 Jun 2010)
@@ -19,8 +19,8 @@
 #ifndef BOOST_PROCESS_ENVIRONMENT_HPP
 #define BOOST_PROCESS_ENVIRONMENT_HPP
 
-#include <string>
 #include <map>
+#include <string>
 
 namespace boost {
 namespace process {

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-06-06 10:21:55 EDT (Sun, 06 Jun 2010)
@@ -68,8 +68,7 @@
  * \throw boost::filesystem::filesystem_error If the file cannot be found
  * in the path.
  */
-inline std::string find_executable_in_path(const std::string &file,
- std::string path = "")
+inline std::string find_executable_in_path(const std::string &file, std::string path = "")
 {
 #if defined(BOOST_POSIX_API)
     BOOST_ASSERT(file.find('/') == std::string::npos);
@@ -85,6 +84,7 @@
         const char *envpath = ::getenv("PATH");
         if (!envpath)
             boost::throw_exception(boost::filesystem::filesystem_error("boost::process::find_executable_in_path: retrieving PATH failed", file, boost::system::errc::make_error_code(boost::system::errc::no_such_file_or_directory)));
+
         path = envpath;
     }
     BOOST_ASSERT(!path.empty());
@@ -103,32 +103,21 @@
     do
     {
         pos2 = path.find(':', pos1);
- std::string dir;
- if(pos2 != std::string::npos)
- dir = path.substr(pos1, pos2 - pos1);
- else
- path.substr(pos1);
-
+ std::string dir = (pos2 != std::string::npos) ? path.substr(pos1, pos2 - pos1) : path.substr(pos1);
         std::string f = dir + (boost::algorithm::ends_with(dir, "/") ? "" : "/") + file;
-
         if (!::access(f.c_str(), X_OK))
             result = f;
         pos1 = pos2 + 1;
- }
- while (pos2 != std::string::npos && result.empty());
-
+ } while (pos2 != std::string::npos && result.empty());
 #elif defined(BOOST_WINDOWS_API)
     const char *exts[] = { "", ".exe", ".com", ".bat", NULL };
     const char **ext = exts;
-
     while (*ext)
     {
         char buf[MAX_PATH];
         char *dummy;
-
         DWORD size = ::SearchPathA(path.empty() ? NULL : path.c_str(), file.c_str(), *ext, MAX_PATH, buf, &dummy);
         BOOST_ASSERT(size < MAX_PATH);
-
         if (size > 0)
         {
             result = buf;
@@ -160,7 +149,6 @@
 #elif defined(BOOST_WINDOWS_API)
     std::string::size_type slash = exe.find_last_of("/\\");
 #endif
-
     if (slash != std::string::npos)
         begin = slash + 1;
 
@@ -185,10 +173,23 @@
  *
  * \return A handle to the new child process.
  */
-template<class Arguments>
-inline child create_child(const std::string &executable, Arguments args,
- context &ctx = DEFAULT_CONTEXT)
+template <class Arguments>
+inline child create_child(const std::string &executable, Arguments args, context ctx = default_context)
 {
+ /*
+ * BEHAVIOR | BEFORE fork/CreateProcess | AFTER fork/CreateProcess
+ * ---------+----------------------------------+---------------------------------
+ * inherit | Windows: duplicate handle and |
+ * | save it in STARTUPINFO |
+ * capture | POSIX: create pipe | POSIX: use one end to initialize
+ * | Windows: create pipe and save | child process object
+ * | one end in STARTUPINFO |
+ * mute | POSIX: open file |
+ * | Windows: open file and save |
+ * | handle in STARTUPINFO |
+ * close | | POSIX: close explicitly
+ */
+
     detail::file_handle fhstdin, fhstdout, fhstderr;
 
     //start structures that represents a std stream.
@@ -201,28 +202,40 @@
     stderr_stream.behavior = ctx.stderr_behavior;
 
     //adjust process name
- std::string p_name = ctx.process_name.empty() ? executable:ctx.process_name;
- args.insert(args.begin(),p_name);
+ std::string p_name = ctx.process_name.empty() ? executable : ctx.process_name;
+ args.insert(args.begin(), p_name);
 
 #if defined(BOOST_POSIX_API)
     child::id_type pid = ::fork();
 
     if (pid == -1)
- boost::throw_exception(boost::system::system_error(boost::system::error_code(errno, boost::system::get_system_category()), "boost::process::detail::posix_start: fork(2) failed"));
+ boost::throw_exception(boost::system::system_error(boost::system::error_code(errno, boost::system::get_system_category()), "boost::process::create_child: fork(2) failed"));
 
     if (pid == 0)
     {
- //configure child pipes
+ // child process
         detail::configure_posix_stream(stdin_stream);
         detail::configure_posix_stream(stdout_stream);
         detail::configure_posix_stream(stderr_stream);
 
- //execve call
         std::pair<std::size_t, char**> argcv = detail::collection_to_posix_argv(args);
         char **envp = detail::environment_to_envp(ctx.environment);
         ::execve(executable.c_str(), argcv.second, envp);
 
- BOOST_ASSERT(false);
+ // error handling in case execve() failed
+ boost::system::system_error e(boost::system::error_code(errno, boost::system::get_system_category()), "boost::process::create_child: execve(2) failed");
+
+ for (std::size_t i = 0; i < argcv.first; ++i)
+ delete[] argcv.second[i];
+ delete[] argcv.second;
+
+ for (std::size_t i = 0; i < env.size(); ++i)
+ delete[] envp[i];
+ delete[] envp;
+
+ ::write(STDERR_FILENO, e.what(), std::strlen(e.what()));
+ ::write(STDERR_FILENO, "\n", 1);
+ std::exit(EXIT_FAILURE);
     }
 
     BOOST_ASSERT(pid > 0);
@@ -304,16 +317,13 @@
     if (!::CloseHandle(pi.hThread))
         boost::throw_exception(boost::system::system_error(boost::system::error_code(::GetLastError(), boost::system::get_system_category()), "boost::process::launch: CloseHandle failed"));
 
- std::cout << "Process handle passado para o child:" << pi.hProcess << std::endl;
     return child(pi.dwProcessId, fhstdin, fhstdout, fhstderr, detail::file_handle(pi.hProcess));
 #endif
 }
 
-inline child create_child(const std::string &executable,
- context &ctx = DEFAULT_CONTEXT)
+inline child create_child(const std::string &executable, context ctx = default_context)
 {
- std::vector<std::string> args ;
- return create_child(executable,args,ctx);
+ return create_child(executable, std::vector<std::string>(), ctx);
 }
 
 }

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-06-06 10:21:55 EDT (Sun, 06 Jun 2010)
@@ -101,13 +101,11 @@
      * \throw boost::system::system_error If the system call used to
      * terminate the process fails.
      */
-
     void terminate(bool force = false) const
     {
 #if defined(BOOST_POSIX_API)
         if (::kill(id_, force ? SIGKILL : SIGTERM) == -1)
             boost::throw_exception(boost::system::system_error(boost::system::error_code(errno, boost::system::get_system_category()), "boost::process::process::terminate: kill(2) failed"));
-
 #elif defined(BOOST_WINDOWS_API)
         HANDLE h = ::OpenProcess(PROCESS_TERMINATE, FALSE, id_);
         if (h == NULL)
@@ -122,6 +120,7 @@
             boost::throw_exception(boost::system::system_error(boost::system::error_code(::GetLastError(), boost::system::get_system_category()), "boost::process::process::terminate: CloseHandle failed"));
 #endif
     }
+
     /**
      * Blocks and waits for the child process to terminate.
      *
@@ -138,18 +137,24 @@
 #if defined(BOOST_POSIX_API)
         int s;
         if (::waitpid(get_id(), &s, 0) == -1)
- boost::throw_exception(boost::system::system_error(boost::system::error_code(errno, boost::system::get_system_category()), "boost::process::child::wait: waitpid(2) failed"));
+ boost::throw_exception(boost::system::system_error(boost::system::error_code(errno, boost::system::get_system_category()), "boost::process::process::wait: waitpid(2) failed"));
         return status(s);
 #elif defined(BOOST_WINDOWS_API)
- std::cout << "Criado com ID " << process_handle_.get() << std::endl;
- if(::WaitForSingleObject(process_handle_.get(),INFINITE) == WAIT_FAILED)
+ // TODO
+ // Boris: Where do we get the process handle from? It should be possible to fetch it
+ // as we do have the process ID saved in the member variable id_. I guess
+ // there must be a Windows API function to get a process handle from a process ID?
+ if (::WaitForSingleObject(process_handle_.get(),INFINITE) == WAIT_FAILED)
         {
- std::cout << "Last error:" << GetLastError() << std::endl;
- std::cout << "Criado com ID " << process_handle_.get() << std::endl;
+ // TODO
+ // Boris: What should happen if WaitForSingleObject() fails? Under what
+ // conditions can it fail?
+ // std::cout << "Last error:" << GetLastError() << std::endl;
+ // std::cout << "Criado com ID " << process_handle_.get() << std::endl;
         }
         DWORD code;
         if (!::GetExitCodeProcess(process_handle_.get(), &code))
- boost::throw_exception(boost::system::system_error(boost::system::error_code(::GetLastError(), boost::system::get_system_category()), "boost::process::child::wait: GetExitCodeProcess failed"));
+ boost::throw_exception(boost::system::system_error(boost::system::error_code(::GetLastError(), boost::system::get_system_category()), "boost::process::process::wait: GetExitCodeProcess failed"));
         return status(code);
 #endif
     }

Modified: sandbox/SOC/2010/process/boost/process/self.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/self.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/self.hpp 2010-06-06 10:21:55 EDT (Sun, 06 Jun 2010)
@@ -22,13 +22,14 @@
 #include <boost/process/config.hpp>
 
 #if defined(BOOST_POSIX_API)
-# include <unistd.h>
+# include <boost/scoped_array.hpp>
+# include <cerrno>
+# include <unistd.h>
 # if defined(__APPLE__)
 # include <crt_externs.h>
 # endif
 #elif defined(BOOST_WINDOWS_API)
 # include <windows.h>
-# include <direct.h>
 #else
 # error "Unsupported platform."
 #endif
@@ -125,19 +126,29 @@
         return e;
     }
 
- static char *get_work_dir()
+ static std::string get_work_dir()
     {
-#if defined(BOOST_POSIX_API)
- int size = pathconf(".",_PC_PATH_MAX);
- char *buffer = (char *)malloc(size);
- if (!buffer)
- BOOST_ASSERT(false);
- return getcwd(buffer, size);
-#elif defined(BOOST_WINDOWS_API)
- char* buffer;
- BOOST_ASSERT((buffer = _getcwd( NULL, 0 )) != NULL);
- return buffer;
-#endif
+#if defined(BOOST_POSIX_API)
+ errno = 0;
+ long size = ::pathconf(".", _PC_PATH_MAX);
+ if (size == -1 && errno)
+ boost::throw_exception(boost::system::system_error(boost::system::error_code(errno, boost::system::get_system_category()), "boost::process::self::get_work_dir: pathconf(2) failed"));
+ else if (size == -1)
+ size = BOOST_PROCESS_POSIX_PATH_MAX;
+ BOOST_ASSERT(size > 0);
+ boost::scoped_array<char> cwd(new char[size]);
+ if (!::getcwd(cwd.get(), size))
+ boost::throw_exception(boost::system::system_error(boost::system::error_code(errno, boost::system::get_system_category()), "boost::process::self::get_work_dir: getcwd(2) failed"));
+ BOOST_ASSERT(cwd[0] != '\0');
+ return cwd.get();
+#elif defined(BOOST_WINDOWS_API)
+ BOOST_ASSERT(MAX_PATH > 0);
+ char cwd[MAX_PATH];
+ if (!::GetCurrentDirectoryA(sizeof(cwd), cwd))
+ boost::throw_exception(boost::system::system_error(boost::system::error_code(::GetLastError(), boost::system::get_system_category()), "boost::process::self::get_work_dir: GetCurrentDirectory failed"));
+ BOOST_ASSERT(cwd[0] != '\0');
+ return cwd;
+#endif
     }
 
 private:

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-06-06 10:21:55 EDT (Sun, 06 Jun 2010)
@@ -39,10 +39,7 @@
  * Status returned by a finalized %child process.
  *
  * This class represents the %status returned by a child process after it
- * has terminated. It only provides that information available under all
- * supported platforms.
- *
- * \see posix_status
+ * has terminated.
  */
 class status
 {
@@ -57,7 +54,11 @@
 #if defined(BOOST_POSIX_API)
         return WIFEXITED(flags_);
 #elif defined(BOOST_WINDOWS_API)
- //TODO: Is that really right?
+ // TODO
+ // Felipe: Is that really right?
+ // Boris: Not sure in the moment. I think we have to check the
+ // sample programs to see if there is a use case where
+ // this is not true?
         return true;
 #endif
     }
@@ -69,7 +70,6 @@
      *
      * \pre exited() is true.
      */
-
     int exit_code() const
     {
         BOOST_ASSERT(exited());
@@ -93,7 +93,9 @@
      * Windows system it contains the exit code only.
      */
     status(int flags)
- : flags_(flags) {}
+ : flags_(flags)
+ {
+ }
 
     /**
      * OS-specific codification of exit status.

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-06-06 10:21:55 EDT (Sun, 06 Jun 2010)
@@ -13,7 +13,7 @@
 /**
  * \file boost/process/stream_behavior.hpp
  *
- * Includes the declaration of the stream_behavior
+ * Includes the declaration of the stream_behavior enumeration.
  *
  */
 
@@ -25,18 +25,17 @@
 namespace boost {
 namespace process {
 
-/*
+/**
  *
- * stream_behavior defines how a stream should behavior
- * from a brand-new child.
+ * Stream behaviors to define how standard streams are passed to a child process.
  *
- * inherit: The stream are inherit from it's father
- * capture: The stream is connected with an anonymous pipe
- * closed: The stream is closed as soon as the process is created
- * dummy: Dummy data will be writed or read from this stream
+ * inherit: A stream is inherited from its parent process.
+ * capture: A stream is redirected to its parent process (anonymous pipe).
+ * mute: A stream is redirected to /dev/null, /dev/zero or NUL.
+ * close: A stream is closed.
  *
  */
-enum stream_behavior { inherit, capture, closed, dummy};
+enum stream_behavior { inherit, capture, mute, close };
 
 }
 }

Modified: sandbox/SOC/2010/process/libs/process/example/create_process.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/example/create_process.cpp (original)
+++ sandbox/SOC/2010/process/libs/process/example/create_process.cpp 2010-06-06 10:21:55 EDT (Sun, 06 Jun 2010)
@@ -11,7 +11,7 @@
 //
 
 #include <boost/process/all.hpp>
-#include <iostream>
+#include <boost/assign/list_of.hpp>
 #include <vector>
 #include <string>
 #include <utility>
@@ -22,15 +22,11 @@
 {
     child c1 = create_child(find_executable_in_path("hostname"));
 
- std::vector<std::string> args;
- args.push_back("-?");
+ std::vector<std::string> args = boost::assign::list_of("-?");
     child c2 = create_child(find_executable_in_path("hostname"), args);
 
     context ctx;
     ctx.environment.insert(std::make_pair("NEW_ENV_VARIABLE", "VALUE"));
- ctx.process_name = "My_process_name";
- ctx.stdin_behavior = stream_behavior::inherit;
- ctx.stdout_behavior = stream_behavior::closed;
- ctx.stderr_behavior = stream_behavior::closed;
+ ctx.stdin_behavior = stream_behavior::close;
     child c3 = create_child(find_executable_in_path("hostname"), args, ctx);
 }


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