Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62289 - in sandbox/SOC/2010/process/boost/process: . detail
From: fotanus_at_[hidden]
Date: 2010-05-27 23:10:00


Author: fotanus
Date: 2010-05-27 23:09:55 EDT (Thu, 27 May 2010)
New Revision: 62289
URL: http://svn.boost.org/trac/boost/changeset/62289

Log:
Formated to ansi style; splited lines longer than 80 characters.

Text files modified:
   sandbox/SOC/2010/process/boost/process/child.hpp | 338 +++++++-------
   sandbox/SOC/2010/process/boost/process/config.hpp | 72 +-
   sandbox/SOC/2010/process/boost/process/context.hpp | 120 ++--
   sandbox/SOC/2010/process/boost/process/detail/file_handle.hpp | 866 +++++++++++++++++++++------------------
   sandbox/SOC/2010/process/boost/process/detail/pipe.hpp | 401 +++++++++--------
   sandbox/SOC/2010/process/boost/process/detail/posix_helpers.hpp | 292 +++++++------
   sandbox/SOC/2010/process/boost/process/detail/stream_detail.hpp | 155 +++---
   sandbox/SOC/2010/process/boost/process/detail/systembuf.hpp | 397 +++++++++--------
   sandbox/SOC/2010/process/boost/process/detail/win32_helpers.hpp | 398 +++++++++--------
   sandbox/SOC/2010/process/boost/process/environment.hpp | 98 ++--
   sandbox/SOC/2010/process/boost/process/operations.hpp | 650 +++++++++++++++--------------
   sandbox/SOC/2010/process/boost/process/pistream.hpp | 230 +++++-----
   sandbox/SOC/2010/process/boost/process/posix_child.hpp | 356 ++++++++--------
   sandbox/SOC/2010/process/boost/process/postream.hpp | 226 +++++-----
   sandbox/SOC/2010/process/boost/process/process.hpp | 357 ++++++++-------
   sandbox/SOC/2010/process/boost/process/self.hpp | 312 +++++++------
   sandbox/SOC/2010/process/boost/process/status.hpp | 209 ++++----
   sandbox/SOC/2010/process/boost/process/stream_behavior.hpp | 70 +-
   18 files changed, 2886 insertions(+), 2661 deletions(-)

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-05-27 23:09:55 EDT (Thu, 27 May 2010)
@@ -1,172 +1,178 @@
-//
-// 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)
-//
-
-/**
- * \file boost/process/child.hpp
- *
- * Includes the declaration of the child class.
- */
+//
+// 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)
+//
+
+/**
+ * \file boost/process/child.hpp
+ *
+ * Includes the declaration of the child class.
+ */
 
-#ifndef BOOST_PROCESS_CHILD_HPP
-#define BOOST_PROCESS_CHILD_HPP
+#ifndef BOOST_PROCESS_CHILD_HPP
+#define BOOST_PROCESS_CHILD_HPP
 #include <iostream>
-#include <boost/process/config.hpp>
+#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
- #error "Unsupported platform."
-#endif
-
-#include <boost/process/process.hpp>
-
-
-#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 <vector>
-
-namespace boost {
-namespace process {
-
-/**
- * Generic implementation of the Child concept.
- *
- * The child class implements the Child concept in an operating system
- * agnostic way.
- */
-class child : public process
-{
-public:
- /**
- * Gets a reference to the child's standard input stream.
- *
- * Returns a reference to a postream object that represents the
- * standard input communication channel with the child process.
- */
- postream &get_stdin() const
- {
- BOOST_ASSERT(stdin_);
- return *stdin_;
- }
-
- /**
- * Gets a reference to the child's standard output stream.
- *
- * Returns a reference to a pistream object that represents the
- * standard output communication channel with the child process.
- */
- pistream &get_stdout() const
- {
- BOOST_ASSERT(stdout_);
- return *stdout_;
- }
-
- /**
- * Gets a reference to the child's standard error stream.
- *
- * Returns a reference to a pistream object that represents the
- * standard error communication channel with the child process.
- */
- pistream &get_stderr() const
- {
- BOOST_ASSERT(stderr_);
- return *stderr_;
- }
-
-
-
- /**
- * Creates a new child object that represents the just spawned child
- * process \a id.
- *
- * The \a fhstdin, \a fhstdout and \a fhstderr file handles represent
- * the parent's handles used to communicate with the corresponding
- * data streams. They needn't be valid but their availability must
- * match the redirections configured by the launcher that spawned this
- * process.
- *
- * The \a fhprocess handle represents a handle to the child process.
- * 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())
- : process(id){
-
- #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())
- stdout_.reset(new pistream(fhstdout));
- if (fhstderr.valid())
- stderr_.reset(new pistream(fhstderr));
- }
-
-
-
-private:
- /**
- * The standard input stream attached to the child process.
- *
- * This postream object holds the communication channel with the
- * child's process standard input. It is stored in a pointer because
- * this field is only valid when the user requested to redirect this
- * data stream.
- */
- boost::shared_ptr<postream> stdin_;
-
- /**
- * The standard output stream attached to the child process.
- *
- * This postream object holds the communication channel with the
- * child's process standard output. It is stored in a pointer because
- * this field is only valid when the user requested to redirect this
- * data stream.
- */
- boost::shared_ptr<pistream> stdout_;
-
- /**
- * The standard error stream attached to the child process.
- *
- * This postream object holds the communication channel with the
- * child's process standard error. It is stored in a pointer because
- * this field is only valid when the user requested to redirect this
- * data stream.
- */
- 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_POSIX_API)
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <cerrno>
+
+#elif defined(BOOST_WINDOWS_API)
+#include <windows.h>
+
+#else
+#error "Unsupported platform."
+#endif
+
+#include <boost/process/process.hpp>
+
+
+#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 <vector>
+
+namespace boost
+{
+namespace process
+{
+
+/**
+ * Generic implementation of the Child concept.
+ *
+ * The child class implements the Child concept in an operating system
+ * agnostic way.
+ */
+class child : public process
+{
+public:
+ /**
+ * Gets a reference to the child's standard input stream.
+ *
+ * Returns a reference to a postream object that represents the
+ * standard input communication channel with the child process.
+ */
+ postream &get_stdin() const
+ {
+ BOOST_ASSERT(stdin_);
+ return *stdin_;
+ }
+
+ /**
+ * Gets a reference to the child's standard output stream.
+ *
+ * Returns a reference to a pistream object that represents the
+ * standard output communication channel with the child process.
+ */
+ pistream &get_stdout() const
+ {
+ BOOST_ASSERT(stdout_);
+ return *stdout_;
+ }
+
+ /**
+ * Gets a reference to the child's standard error stream.
+ *
+ * Returns a reference to a pistream object that represents the
+ * standard error communication channel with the child process.
+ */
+ pistream &get_stderr() const
+ {
+ BOOST_ASSERT(stderr_);
+ return *stderr_;
+ }
+
+
+
+ /**
+ * Creates a new child object that represents the just spawned child
+ * process \a id.
+ *
+ * The \a fhstdin, \a fhstdout and \a fhstderr file handles represent
+ * the parent's handles used to communicate with the corresponding
+ * data streams. They needn't be valid but their availability must
+ * match the redirections configured by the launcher that spawned this
+ * process.
+ *
+ * The \a fhprocess handle represents a handle to the child process.
+ * 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())
+ : process(id)
+ {
+
+#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())
+ stdout_.reset(new pistream(fhstdout));
+ if (fhstderr.valid())
+ stderr_.reset(new pistream(fhstderr));
+ }
+
+
+
+private:
+ /**
+ * The standard input stream attached to the child process.
+ *
+ * This postream object holds the communication channel with the
+ * child's process standard input. It is stored in a pointer because
+ * this field is only valid when the user requested to redirect this
+ * data stream.
+ */
+ boost::shared_ptr<postream> stdin_;
+
+ /**
+ * The standard output stream attached to the child process.
+ *
+ * This postream object holds the communication channel with the
+ * child's process standard output. It is stored in a pointer because
+ * this field is only valid when the user requested to redirect this
+ * data stream.
+ */
+ boost::shared_ptr<pistream> stdout_;
+
+ /**
+ * The standard error stream attached to the child process.
+ *
+ * This postream object holds the communication channel with the
+ * child's process standard error. It is stored in a pointer because
+ * this field is only valid when the user requested to redirect this
+ * data stream.
+ */
+ 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;
 
 } ;
-}
 }
-#endif
+}
+#endif

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-05-27 23:09:55 EDT (Thu, 27 May 2010)
@@ -1,41 +1,41 @@
-//
-// 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
+//
+// 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/config.hpp
- *
- * Defines macros that are used by the library's code to determine the
- * operating system it is running under and the features it supports.
- */
+/**
+ * \file boost/process/config.hpp
+ *
+ * Defines macros that are used by the library's code to determine the
+ * operating system it is running under and the features it supports.
+ */
 
-#ifndef BOOST_PROCESS_CONFIG_HPP
-#define BOOST_PROCESS_CONFIG_HPP
+#ifndef BOOST_PROCESS_CONFIG_HPP
+#define BOOST_PROCESS_CONFIG_HPP
 
-#include <boost/config.hpp>
-#include <boost/system/config.hpp>
+#include <boost/config.hpp>
+#include <boost/system/config.hpp>
 
-#if defined(BOOST_POSIX_API) || defined(BOOST_PROCESS_DOXYGEN)
-# if !defined(BOOST_PROCESS_POSIX_PATH_MAX)
-/**
- * The macro BOOST_PROCESS_POSIX_PATH_MAX is set to a positive integer
- * value which specifies the system's maximal supported path length.
- * 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.
- */
-# define BOOST_PROCESS_POSIX_PATH_MAX 259
-# endif
-#endif
+#if defined(BOOST_POSIX_API) || defined(BOOST_PROCESS_DOXYGEN)
+# if !defined(BOOST_PROCESS_POSIX_PATH_MAX)
+/**
+ * The macro BOOST_PROCESS_POSIX_PATH_MAX is set to a positive integer
+ * value which specifies the system's maximal supported path length.
+ * 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.
+ */
+# define BOOST_PROCESS_POSIX_PATH_MAX 259
+# endif
+#endif
 
-#endif
+#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-05-27 23:09:55 EDT (Thu, 27 May 2010)
@@ -1,75 +1,79 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
+//
+// Boost.Process
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2006, 2007 Julio M. Merino Vidal
+// Copyright (c) 2008, 2009 Boris Schaeling
 // Copyright (c) 2010 Boris Schaeling, Felipe Tanus
-//
-// 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/context.hpp
- *
+//
+// 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/context.hpp
+ *
  * Includes the declaration of the context struct.
  *
- */
+ */
 
-#include <boost/process/config.hpp>
+#include <boost/process/config.hpp>
 #include <map>
 #include <boost/process/stream_behavior.hpp>
 #include <boost/process/environment.hpp>
 #include <boost/process/self.hpp>
 
 
-#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: ...
- *
- */
-struct context{
-
- environment_t environment; //default: empty
-
- std::string process_name; //default: empty
- //io_service *ioservice; //default: NULL
- std::string work_dir;
-
- stream_behavior stdin_behavior;
- stream_behavior stdout_behavior;
- stream_behavior stderr_behavior;
-
- context(){
- stdin_behavior = inherit;
- stdout_behavior = inherit;
- stderr_behavior = inherit;
- work_dir = self::get_work_dir();
- environment = self::get_environment();
+#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: ...
+ *
+ */
+struct context
+{
+
+ environment_t environment; //default: empty
+
+ std::string process_name; //default: empty
+ //io_service *ioservice; //default: NULL
+ std::string work_dir;
+
+ stream_behavior stdin_behavior;
+ stream_behavior stdout_behavior;
+ stream_behavior stderr_behavior;
+
+ context()
+ {
+ 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.

Modified: sandbox/SOC/2010/process/boost/process/detail/file_handle.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/detail/file_handle.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/detail/file_handle.hpp 2010-05-27 23:09:55 EDT (Thu, 27 May 2010)
@@ -1,422 +1,466 @@
-//
-// 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)
-//
-
-/**
- * \file boost/process/detail/file_handle.hpp
- *
- * Includes the declaration of the file_handle class. This file is for
- * internal usage only and must not be included by the library user.
- */
-
-#ifndef BOOST_PROCESS_DETAIL_FILE_HANDLE_HPP
-#define BOOST_PROCESS_DETAIL_FILE_HANDLE_HPP
-
-#include <boost/process/config.hpp>
-
-#if defined(BOOST_POSIX_API)
- #include <cerrno>
- #include <unistd.h>
-#elif defined(BOOST_WINDOWS_API)
- #include <windows.h>
-#else
- #error "Unsupported platform."
-#endif
-
-#include <boost/assert.hpp>
-#include <boost/system/system_error.hpp>
-#include <boost/throw_exception.hpp>
-#include <stdio.h>
-
-namespace boost {
-namespace process {
-namespace detail {
-
-/**
- * Simple RAII model for system file handles.
- *
- * The \a file_handle class is a simple RAII model for native system file
- * handles. This class wraps one of such handles grabbing its ownership,
- * and automaticaly closes it upon destruction. It is basically used
- * inside the library to avoid leaking open file handles, shall an
- * unexpected execution trace occur.
- *
- * A \a file_handle object can be copied but doing so invalidates the
- * source object. There can only be a single valid \a file_handle object
- * for a given system file handle. This is similar to std::auto_ptr's
- * semantics.
- *
- * This class also provides some convenience methods to issue special file
- * operations under their respective platforms.
- */
-class file_handle
+//
+// 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)
+//
+
+/**
+ * \file boost/process/detail/file_handle.hpp
+ *
+ * Includes the declaration of the file_handle class. This file is for
+ * internal usage only and must not be included by the library user.
+ */
+
+#ifndef BOOST_PROCESS_DETAIL_FILE_HANDLE_HPP
+#define BOOST_PROCESS_DETAIL_FILE_HANDLE_HPP
+
+#include <boost/process/config.hpp>
+
+#if defined(BOOST_POSIX_API)
+#include <cerrno>
+#include <unistd.h>
+#elif defined(BOOST_WINDOWS_API)
+#include <windows.h>
+#else
+#error "Unsupported platform."
+#endif
+
+#include <boost/assert.hpp>
+#include <boost/system/system_error.hpp>
+#include <boost/throw_exception.hpp>
+#include <stdio.h>
+
+namespace boost
+{
+namespace process
+{
+namespace detail
+{
+
+/**
+ * Simple RAII model for system file handles.
+ *
+ * The \a file_handle class is a simple RAII model for native system file
+ * handles. This class wraps one of such handles grabbing its ownership,
+ * and automaticaly closes it upon destruction. It is basically used
+ * inside the library to avoid leaking open file handles, shall an
+ * unexpected execution trace occur.
+ *
+ * A \a file_handle object can be copied but doing so invalidates the
+ * source object. There can only be a single valid \a file_handle object
+ * for a given system file handle. This is similar to std::auto_ptr's
+ * semantics.
+ *
+ * This class also provides some convenience methods to issue special file
+ * operations under their respective platforms.
+ */
+class file_handle
 {
 public:
 #if defined(BOOST_PROCESS_DOXYGEN)
- /**
- * Opaque name for the native handle type.
- *
- * Each operating system identifies file handles using a specific type.
- * The \a handle_type type is used to transparently refer to file
- * handles regarless of the operating system in which this class is
- * used.
- *
- * If this class is used on a POSIX system, \a NativeSystemHandle is
- * an integer type while it is a \a HANDLE on a Windows system.
- */
- typedef NativeSystemHandle handle_type;
-#elif defined(BOOST_POSIX_API)
- typedef int handle_type;
-#elif defined(BOOST_WINDOWS_API)
- typedef HANDLE handle_type;
-#endif
-
- /**
- * Constructs an invalid file handle.
- *
- * This constructor creates a new \a file_handle object that represents
- * an invalid file handle. An invalid file handle can be copied but
- * cannot be manipulated in any way (except checking for its validity).
- *
- * \see valid()
- */
- file_handle()
- : handle_(invalid_value()){
- }
+ /**
+ * Opaque name for the native handle type.
+ *
+ * Each operating system identifies file handles using a specific type.
+ * The \a handle_type type is used to transparently refer to file
+ * handles regarless of the operating system in which this class is
+ * used.
+ *
+ * If this class is used on a POSIX system, \a NativeSystemHandle is
+ * an integer type while it is a \a HANDLE on a Windows system.
+ */
+ typedef NativeSystemHandle handle_type;
+#elif defined(BOOST_POSIX_API)
+ typedef int handle_type;
+#elif defined(BOOST_WINDOWS_API)
+ typedef HANDLE handle_type;
+#endif
+
+ /**
+ * Constructs an invalid file handle.
+ *
+ * This constructor creates a new \a file_handle object that represents
+ * an invalid file handle. An invalid file handle can be copied but
+ * cannot be manipulated in any way (except checking for its validity).
+ *
+ * \see valid()
+ */
+ file_handle()
+ : handle_(invalid_value())
+ {
+ }
+
+ /**
+ * Constructs a new file handle from a native file handle.
+ *
+ * This constructor creates a new \a file_handle object that takes
+ * ownership of the given \a h native file handle. The user must not
+ * close \a h on his own during the lifetime of the new object.
+ * Ownership can be reclaimed using release().
+ *
+ * \pre The native file handle must be valid; a close operation must
+ * succeed on it.
+ * \see release()
+ */
+ file_handle(handle_type h)
+ : handle_(h)
+ {
+ BOOST_ASSERT(handle_ != invalid_value());
+ }
+
+ /**
+ * Copy constructor; invalidates the source handle.
+ *
+ * This copy constructor creates a new file handle from a given one.
+ * Ownership of the native file handle is transferred to the new
+ * object, effectively invalidating the source file handle. This
+ * avoids having two live \a file_handle objects referring to the
+ * same native file handle. The source file handle needs not be
+ * valid in the name of simplicity.
+ *
+ * \post The source file handle is invalid.
+ * \post The new file handle owns the source's native file handle.
+ */
+ file_handle(const file_handle &fh)
+ : handle_(fh.handle_)
+ {
+ fh.handle_ = invalid_value();
+ }
+
+ /**
+ * Releases resources if the handle is valid.
+ *
+ * If the file handle is valid, the destructor closes it.
+ *
+ * \see valid()
+ */
+ ~file_handle()
+ {
+ if (valid())
+ close();
+ }
+
+ /**
+ * Assignment operator; invalidates the source handle.
+ *
+ * This assignment operator transfers ownership of the RHS file
+ * handle to the LHS one, effectively invalidating the source file
+ * handle. This avoids having two live \a file_handle objects
+ * referring to the same native file handle. The source file
+ * handle needs not be valid in the name of simplicity.
+ *
+ * \post The RHS file handle is invalid.
+ * \post The LHS file handle owns RHS' native file handle.
+ * \return A reference to the LHS file handle.
+ */
+ file_handle &operator=(const file_handle &fh)
+ {
+ handle_ = fh.handle_;
+ fh.handle_ = invalid_value();
+ return *this;
+ }
+
+ /**
+ * Checks whether the file handle is valid or not.
+ *
+ * Returns a boolean indicating whether the file handle is valid or
+ * not. If the file handle is invalid, no other methods can be
+ * executed other than the destructor.
+ *
+ * \return true if the file handle is valid; false otherwise.
+ */
+ bool valid()
+ {
+ return handle_ != invalid_value();
+ }
+
+
+ /**
+ * Reclaims ownership of the native file handle.
+ *
+ * Explicitly reclaims ownership of the native file handle contained
+ * in the \a file_handle object, returning the native file handle.
+ * The caller is responsible of closing it later on.
+ *
+ * \pre The file handle is valid.
+ * \post The file handle is invalid.
+ * \return The native file handle.
+ */
+ handle_type release()
+ {
+ BOOST_ASSERT(valid());
+
+ handle_type h = handle_;
+ handle_ = invalid_value();
+ return h;
+ }
+
+ /**
+ * Gets the native file handle.
+ *
+ * Returns the native file handle for the \a file_handle object.
+ * The caller can issue any operation on it except closing it.
+ * If closing is required, release() shall be used.
+ *
+ * \pre The file handle is valid.
+ * \post The file handle is valid.
+ * \return The native file handle.
+ */
+ handle_type get()
+ {
+ BOOST_ASSERT(valid());
 
- /**
- * Constructs a new file handle from a native file handle.
- *
- * This constructor creates a new \a file_handle object that takes
- * ownership of the given \a h native file handle. The user must not
- * close \a h on his own during the lifetime of the new object.
- * Ownership can be reclaimed using release().
- *
- * \pre The native file handle must be valid; a close operation must
- * succeed on it.
- * \see release()
- */
- file_handle(handle_type h)
- : handle_(h){
- BOOST_ASSERT(handle_ != invalid_value());
- }
-
- /**
- * Copy constructor; invalidates the source handle.
- *
- * This copy constructor creates a new file handle from a given one.
- * Ownership of the native file handle is transferred to the new
- * object, effectively invalidating the source file handle. This
- * avoids having two live \a file_handle objects referring to the
- * same native file handle. The source file handle needs not be
- * valid in the name of simplicity.
- *
- * \post The source file handle is invalid.
- * \post The new file handle owns the source's native file handle.
- */
- file_handle(const file_handle &fh)
- : handle_(fh.handle_){
- fh.handle_ = invalid_value();
- }
-
- /**
- * Releases resources if the handle is valid.
- *
- * If the file handle is valid, the destructor closes it.
- *
- * \see valid()
- */
- ~file_handle(){
- if (valid())
- close();
- }
-
- /**
- * Assignment operator; invalidates the source handle.
- *
- * This assignment operator transfers ownership of the RHS file
- * handle to the LHS one, effectively invalidating the source file
- * handle. This avoids having two live \a file_handle objects
- * referring to the same native file handle. The source file
- * handle needs not be valid in the name of simplicity.
- *
- * \post The RHS file handle is invalid.
- * \post The LHS file handle owns RHS' native file handle.
- * \return A reference to the LHS file handle.
- */
- file_handle &operator=(const file_handle &fh){
- handle_ = fh.handle_;
- fh.handle_ = invalid_value();
- return *this;
- }
-
- /**
- * Checks whether the file handle is valid or not.
- *
- * Returns a boolean indicating whether the file handle is valid or
- * not. If the file handle is invalid, no other methods can be
- * executed other than the destructor.
- *
- * \return true if the file handle is valid; false otherwise.
- */
- bool valid(){
- return handle_ != invalid_value();
- }
-
-
- /**
- * Reclaims ownership of the native file handle.
- *
- * Explicitly reclaims ownership of the native file handle contained
- * in the \a file_handle object, returning the native file handle.
- * The caller is responsible of closing it later on.
- *
- * \pre The file handle is valid.
- * \post The file handle is invalid.
- * \return The native file handle.
- */
- handle_type release(){
- BOOST_ASSERT(valid());
-
- handle_type h = handle_;
- handle_ = invalid_value();
- return h;
- }
-
- /**
- * Gets the native file handle.
- *
- * Returns the native file handle for the \a file_handle object.
- * The caller can issue any operation on it except closing it.
- * If closing is required, release() shall be used.
- *
- * \pre The file handle is valid.
- * \post The file handle is valid.
- * \return The native file handle.
- */
- handle_type get(){
- BOOST_ASSERT(valid());
-
- return handle_;
- }
+ return handle_;
+ }
 
 #if defined(BOOST_POSIX_API) || defined(BOOST_PROCESS_DOXYGEN)
 
- /**
- * Closes the file handle.
- *
- * Explicitly closes the file handle, which must be valid. Upon
- * exit, the handle is not valid any more.
- *
- * \pre The file handle is valid.
- * \post The file handle is invalid.
- * \post The native file handle is closed.
- */
- void close(){
- BOOST_ASSERT(valid());
- ::close(handle_);
- handle_ = invalid_value();
- }
-
- /**
- * Changes the native file handle to the given one.
- *
- * Given a new native file handle \a h, this operation assigns this
- * handle to the current object, closing its old native file handle.
- * In other words, it first calls dup2() to remap the old handle to
- * the new one and then closes the old handle.
- *
- * If \a h is open, it is automatically closed by dup2().
- *
- * This operation is only available in POSIX systems.
- *
- * \pre The file handle is valid.
- * \pre The native file handle \a h is valid; i.e., it must be
- * closeable.
- * \post The file handle's native file handle is \a h.
- * \throw boost::system::system_error If the internal remapping
- * operation fails.
- */
- void posix_remap(handle_type &h){
-
- BOOST_ASSERT(valid());
-
- /*
- if (::dup2(handle_, h) == -1)
- boost::throw_exception(boost::system::system_error(boost::system::error_code(errno, boost::system::get_system_category()), "boost::process::detail::file_handle::posix_remap: dup2(2) failed"));
-
- if (::close(handle_) == -1){
- ::close(h);
- boost::throw_exception(boost::system::system_error(boost::system::error_code(errno, boost::system::get_system_category()), "boost::process::detail::file_handle::posix_remap: close(2) failed"));
- } */
-
- if( ::dup2(handle_,h) == -1 ){
- boost::throw_exception(boost::system::system_error(boost::system::error_code(errno, boost::system::get_system_category()), "boost::process::detail::file_handle::posix_remap: dup2(2) failed"));
-
- }
- handle_ = h;
- }
-
- /**
- * Duplicates an open native file handle.
- *
- * Given a native file handle \a h1, this routine duplicates it so
- * that it ends up being identified by the native file handle \a h2
- * and returns a new \a file_handle owning \a h2.
- *
- * This operation is only available in POSIX systems.
- *
- * \pre The native file handle \a h1 is open.
- * \pre The native file handle \a h2 is valid (non-negative).
- * \post The native file handle \a h1 is closed.
- * \post The native file handle \a h2 is the same as the old \a h1
- * from the operating system's point of view.
- * \return A new \a file_handle object that owns \a h2.
- * \throw boost::system::system_error If dup2() fails.
- */
- static file_handle duplicate(int h1, int h2)
- {
- if (::dup2(h1, h2) == -1)
- boost::throw_exception(boost::system::system_error(boost::system::error_code(errno, boost::system::get_system_category()), "boost::process::detail::file_handle::posix_dup: dup2(2) failed"));
-
- return file_handle(h2);
- }
-#endif
-#if defined(BOOST_WINDOWS_API) || defined(BOOST_PROCESS_DOXYGEN)
-
- /**
- * Closes the file handle.
- *
- * Explicitly closes the file handle, which must be valid. Upon
- * exit, the handle is not valid any more.
- *
- * \pre The file handle is valid.
- * \post The file handle is invalid.
- * \post The native file handle is closed.
- */
- void close(){
- BOOST_ASSERT(valid());
- ::CloseHandle(handle_);
- handle_ = invalid_value();
- }
-
- /**
- * Duplicates the \a h native file handle.
- *
- * Given a native file handle \a h, this routine constructs a new
- * \a file_handle object that owns a new duplicate of \a h. The
- * duplicate's inheritable flag is set to the value of \a inheritable.
- *
- * This operation is only available in Windows systems.
- *
- * \pre The native file handle \a h is valid.
- * \return A file handle owning a duplicate of \a h.
- * \throw boost::system::system_error If DuplicateHandle() fails.
- */
- static file_handle win32_dup(HANDLE h, bool inheritable){
- HANDLE h2;
-
- if ( ::DuplicateHandle(::GetCurrentProcess(), h,
- ::GetCurrentProcess(), &h2, 0,
- inheritable ? TRUE : FALSE, DUPLICATE_SAME_ACCESS) ==0 )
- boost::throw_exception(boost::system::system_error(
- boost::system::error_code(::GetLastError(),
- boost::system::get_system_category()),
- "boost::process::detail::file_handle::win32_dup: DuplicateHandle failed"));
-
-
- return file_handle(h2);
- }
-
- /**
- * Creates a new duplicate of a standard file handle.
- *
- * Constructs a new \a file_handle object that owns a duplicate of a
- * standard file handle. The \a d parameter specifies which standard
- * file handle to duplicate and can be one of \a STD_INPUT_HANDLE,
- * \a STD_OUTPUT_HANDLE or \a STD_ERROR_HANDLE. The duplicate's
- * inheritable flag is set to the value of \a inheritable.
- *
- * This operation is only available in Windows systems.
- *
- * \pre \a d refers to one of the standard handles as described above.
- * \return A file handle owning a duplicate of the standard handle
- * referred to by \a d.
- * \throw boost::system::system_error If GetStdHandle() or
- * DuplicateHandle() fails.
- */
-
- static file_handle win32_dup_std(DWORD d, bool inheritable){
- BOOST_ASSERT(d == STD_INPUT_HANDLE || d == STD_OUTPUT_HANDLE || d == STD_ERROR_HANDLE);
-
-
- HANDLE h = ::GetStdHandle(d);
- if (h == INVALID_HANDLE_VALUE)
- boost::throw_exception(boost::system::system_error(boost::system::error_code(::GetLastError(), boost::system::get_system_category()), "boost::process::detail::file_handle::win32_std: GetStdHandle failed"));
-
- file_handle dh = win32_dup(h, inheritable);
- return dh;
- }
-
-
- /**
- * Changes the file handle's inheritable flag.
- *
- * Changes the file handle's inheritable flag to \a i. It is not
- * necessary for the file handle's flag to be different than \a i.
- *
- * This operation is only available in Windows systems.
- *
- * \pre The file handle is valid.
- * \post The native file handle's inheritable flag is set to \a i.
- * \throw boost::system::system_error If the property change fails.
- */
- void win32_set_inheritable(bool i)
- {
- BOOST_ASSERT(valid());
-
- if (!::SetHandleInformation(handle_, HANDLE_FLAG_INHERIT, i ? HANDLE_FLAG_INHERIT : 0))
- boost::throw_exception(boost::system::system_error(boost::system::error_code(::GetLastError(), boost::system::get_system_category()), "boost::process::detail::file_handle::win32_set_inheritable: SetHandleInformation failed"));
- }
-#endif
+ /**
+ * Closes the file handle.
+ *
+ * Explicitly closes the file handle, which must be valid. Upon
+ * exit, the handle is not valid any more.
+ *
+ * \pre The file handle is valid.
+ * \post The file handle is invalid.
+ * \post The native file handle is closed.
+ */
+ void close()
+ {
+ BOOST_ASSERT(valid());
+ ::close(handle_);
+ handle_ = invalid_value();
+ }
+
+ /**
+ * Changes the native file handle to the given one.
+ *
+ * Given a new native file handle \a h, this operation assigns this
+ * handle to the current object, closing its old native file handle.
+ * In other words, it first calls dup2() to remap the old handle to
+ * the new one and then closes the old handle.
+ *
+ * If \a h is open, it is automatically closed by dup2().
+ *
+ * This operation is only available in POSIX systems.
+ *
+ * \pre The file handle is valid.
+ * \pre The native file handle \a h is valid; i.e., it must be
+ * closeable.
+ * \post The file handle's native file handle is \a h.
+ * \throw boost::system::system_error If the internal remapping
+ * operation fails.
+ */
+ void posix_remap(handle_type &h)
+ {
+
+ BOOST_ASSERT(valid());
+
+ if (::dup2(handle_, h) == -1)
+ boost::throw_exception(boost::system::system_error(
+ boost::system::error_code(errno,
+ boost::system::get_system_category()),
+ "boost::process::detail::file_handle::posix_remap: \
+ dup2(2) failed"));
+
+ if (::close(handle_) == -1){
+ ::close(h);
+ boost::throw_exception(boost::system::system_error(
+ boost::system::error_code(errno,
+ boost::system::get_system_category()),
+ "boost::process::detail::file_handle::posix_remap:\
+ close(2) failed"));
+ }
+
+ if( ::dup2(handle_,h) == -1 )
+ {
+ boost::throw_exception(boost::system::system_error(
+ boost::system::error_code(errno,
+ boost::system::get_system_category()),
+ "boost::process::detail::file_handle::posix_remap:\
+ dup2(2) failed"));
 
-private:
- /**
- * Internal handle value.
- *
- * This variable holds the native handle value for the file handle
- * hold by this object. It is interesting to note that this needs
- * to be mutable because the copy constructor and the assignment
- * operator invalidate the source object.
- */
- mutable handle_type handle_;
-
- /**
- * Constant function representing an invalid handle value.
- *
- * Returns the platform-specific handle value that represents an
- * invalid handle. This is a constant function rather than a regular
- * constant because, in the latter case, we cannot define it under
- * Windows due to the value being of a complex type.
- */
- static const handle_type invalid_value(){
- #if defined(BOOST_POSIX_API)
- return -1;
- #elif defined(BOOST_WINDOWS_API)
- return INVALID_HANDLE_VALUE;
- #endif
         }
-};
+ handle_ = h;
+ }
 
-}
-}
-}
+ /**
+ * Duplicates an open native file handle.
+ *
+ * Given a native file handle \a h1, this routine duplicates it so
+ * that it ends up being identified by the native file handle \a h2
+ * and returns a new \a file_handle owning \a h2.
+ *
+ * This operation is only available in POSIX systems.
+ *
+ * \pre The native file handle \a h1 is open.
+ * \pre The native file handle \a h2 is valid (non-negative).
+ * \post The native file handle \a h1 is closed.
+ * \post The native file handle \a h2 is the same as the old \a h1
+ * from the operating system's point of view.
+ * \return A new \a file_handle object that owns \a h2.
+ * \throw boost::system::system_error If dup2() fails.
+ */
+ static file_handle duplicate(int h1, int h2)
+ {
+ if (::dup2(h1, h2) == -1)
+ boost::throw_exception(boost::system::system_error(
+ boost::system::error_code(errno,
+ boost::system::get_system_category()),
+ "boost::process::detail::file_handle::posix_dup:\
+ dup2(2) failed"));
+
+ return file_handle(h2);
+ }
+#endif
+#if defined(BOOST_WINDOWS_API) || defined(BOOST_PROCESS_DOXYGEN)
+
+ /**
+ * Closes the file handle.
+ *
+ * Explicitly closes the file handle, which must be valid. Upon
+ * exit, the handle is not valid any more.
+ *
+ * \pre The file handle is valid.
+ * \post The file handle is invalid.
+ * \post The native file handle is closed.
+ */
+ void close()
+ {
+ BOOST_ASSERT(valid());
+ ::CloseHandle(handle_);
+ handle_ = invalid_value();
+ }
+
+ /**
+ * Duplicates the \a h native file handle.
+ *
+ * Given a native file handle \a h, this routine constructs a new
+ * \a file_handle object that owns a new duplicate of \a h. The
+ * duplicate's inheritable flag is set to the value of \a inheritable.
+ *
+ * This operation is only available in Windows systems.
+ *
+ * \pre The native file handle \a h is valid.
+ * \return A file handle owning a duplicate of \a h.
+ * \throw boost::system::system_error If DuplicateHandle() fails.
+ */
+ static file_handle win32_dup(HANDLE h, bool inheritable)
+ {
+ HANDLE h2;
+
+ if (::DuplicateHandle(::GetCurrentProcess(), h,
+ ::GetCurrentProcess(), &h2, 0,
+ inheritable ? TRUE : FALSE, DUPLICATE_SAME_ACCESS) ==0 )
+ boost::throw_exception(boost::system::system_error(
+ boost::system::error_code(::GetLastError(),
+ boost::system::get_system_category()),
+ "boost::process::detail::file_handle::win32_dup:\
+ DuplicateHandle failed"));
+
+
+ return file_handle(h2);
+ }
+
+ /**
+ * Creates a new duplicate of a standard file handle.
+ *
+ * Constructs a new \a file_handle object that owns a duplicate of a
+ * standard file handle. The \a d parameter specifies which standard
+ * file handle to duplicate and can be one of \a STD_INPUT_HANDLE,
+ * \a STD_OUTPUT_HANDLE or \a STD_ERROR_HANDLE. The duplicate's
+ * inheritable flag is set to the value of \a inheritable.
+ *
+ * This operation is only available in Windows systems.
+ *
+ * \pre \a d refers to one of the standard handles as described above.
+ * \return A file handle owning a duplicate of the standard handle
+ * referred to by \a d.
+ * \throw boost::system::system_error If GetStdHandle() or
+ * DuplicateHandle() fails.
+ */
+
+ static file_handle win32_dup_std(DWORD d, bool inheritable)
+ {
+ BOOST_ASSERT(d == STD_INPUT_HANDLE || d == STD_OUTPUT_HANDLE
+ || d == STD_ERROR_HANDLE);
+
+
+ HANDLE h = ::GetStdHandle(d);
+ if (h == INVALID_HANDLE_VALUE)
+ boost::throw_exception(boost::system::system_error(
+ boost::system::error_code(::GetLastError(),
+ boost::system::get_system_category()),
+ "boost::process::detail::file_handle::win32_std:
+ GetStdHandle failed"));
+
+ file_handle dh = win32_dup(h, inheritable);
+ return dh;
+ }
+
+
+ /**
+ * Changes the file handle's inheritable flag.
+ *
+ * Changes the file handle's inheritable flag to \a i. It is not
+ * necessary for the file handle's flag to be different than \a i.
+ *
+ * This operation is only available in Windows systems.
+ *
+ * \pre The file handle is valid.
+ * \post The native file handle's inheritable flag is set to \a i.
+ * \throw boost::system::system_error If the property change fails.
+ */
+ void win32_set_inheritable(bool i)
+ {
+ BOOST_ASSERT(valid());
+
+ if (!::SetHandleInformation(handle_, HANDLE_FLAG_INHERIT, i ?
+ HANDLE_FLAG_INHERIT : 0))
+ boost::throw_exception(boost::system::system_error(
+ boost::system::error_code(::GetLastError(),
+ boost::system::get_system_category()),
+ "boost::process::detail::file_handle::win32_set_inheritable:\
+ SetHandleInformation failed"));
+ }
+#endif
+
+private:
+ /**
+ * Internal handle value.
+ *
+ * This variable holds the native handle value for the file handle
+ * hold by this object. It is interesting to note that this needs
+ * to be mutable because the copy constructor and the assignment
+ * operator invalidate the source object.
+ */
+ mutable handle_type handle_;
+
+ /**
+ * Constant function representing an invalid handle value.
+ *
+ * Returns the platform-specific handle value that represents an
+ * invalid handle. This is a constant function rather than a regular
+ * constant because, in the latter case, we cannot define it under
+ * Windows due to the value being of a complex type.
+ */
+ static const handle_type invalid_value()
+ {
+#if defined(BOOST_POSIX_API)
+ return -1;
+#elif defined(BOOST_WINDOWS_API)
+ return INVALID_HANDLE_VALUE;
+#endif
+ }
+};
+
+}
+}
+}
 
-#endif
+#endif

Modified: sandbox/SOC/2010/process/boost/process/detail/pipe.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/detail/pipe.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/detail/pipe.hpp 2010-05-27 23:09:55 EDT (Thu, 27 May 2010)
@@ -1,187 +1,216 @@
-//
-// 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)
-//
-
-/**
- * \file boost/process/detail/pipe.hpp
- *
- * Includes the declaration of the pipe class. This file is for
- * internal usage only and must not be included by the library user.
- */
-
-#ifndef BOOST_PROCESS_DETAIL_PIPE_HPP
-#define BOOST_PROCESS_DETAIL_PIPE_HPP
-
-#include <boost/process/config.hpp>
-
-#if defined(BOOST_POSIX_API)
-# include <unistd.h>
-# include <cerrno>
-#elif defined(BOOST_WINDOWS_API)
-# if defined(BOOST_PROCESS_WINDOWS_USE_NAMED_PIPE)
-# include <boost/lexical_cast.hpp>
-# include <string>
-# endif
-# include <windows.h>
-#else
-# error "Unsupported platform."
-#endif
-
-#include <boost/process/detail/file_handle.hpp>
-#include <boost/system/system_error.hpp>
-#include <boost/throw_exception.hpp>
-
-namespace boost {
-namespace process {
-namespace detail {
-
-/**
- * Simple RAII model for anonymous pipes.
- *
- * The pipe class is a simple RAII model for anonymous pipes. It
- * provides a portable constructor that allocates a new %pipe and creates
- * a pipe object that owns the two file handles associated to it: the
- * read end and the write end.
- *
- * These handles can be retrieved for modification according to
- * file_handle semantics. Optionally, their ownership can be transferred
- * to external \a file_handle objects which comes handy when the two
- * ends need to be used in different places (i.e. after a POSIX fork()
- * system call).
- *
- * Pipes can be copied following the same semantics as file handles.
- * In other words, copying a %pipe object invalidates the source one.
- *
- * \see file_handle
- */
-class pipe
-{
-public:
- /**
- * Creates a new %pipe.
- *
- * The default pipe constructor allocates a new anonymous %pipe
- * and assigns its ownership to the created pipe object. On Windows
- * when the macro BOOST_PROCESS_WINDOWS_USE_NAMED_PIPE is defined
- * a named pipe is created. This is required if asynchronous I/O
- * should be used as asynchronous I/O is only supported by named
- * pipes on Windows.
- *
- * \throw boost::system::system_error If the anonymous %pipe
- * creation fails.
- */
- pipe(){
- file_handle::handle_type hs[2];
-
- #if defined(BOOST_POSIX_API)
- if (::pipe(hs) == -1)
- boost::throw_exception(boost::system::system_error(
- boost::system::error_code(
- errno, boost::system::get_system_category()),
- "boost::process::detail::pipe::pipe: pipe(2) failed"));
- #elif defined(BOOST_WINDOWS_API)
-
- SECURITY_ATTRIBUTES sa;
- ZeroMemory(&sa, sizeof(sa));
- sa.nLength = sizeof(sa);
-
- sa.lpSecurityDescriptor = NULL;
- sa.bInheritHandle = TRUE;
-
- #if defined(BOOST_PROCESS_WINDOWS_USE_NAMED_PIPE)
- static unsigned int nextid = 0;
- std::string pipe = "\\\\.\\pipe\\boost_process_" + boost::lexical_cast<std::string>(::GetCurrentProcessId()) + "_" + boost::lexical_cast<std::string>(nextid++);
- hs[0] = ::CreateNamedPipeA(pipe.c_str(), PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED, 0, 1, 8192, 8192, 0, &sa);
- if (hs[0] == INVALID_HANDLE_VALUE)
- boost::throw_exception(boost::system::system_error(::GetLastError(), boost::system::system_category, "boost::process::detail::pipe::pipe: CreateNamedPipe failed"));
- hs[1] = ::CreateFileA(pipe.c_str(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
- if (hs[1] == INVALID_HANDLE_VALUE)
- boost::throw_exception(boost::system::system_error(::GetLastError(), boost::system::system_category, "boost::process::detail::pipe::pipe: CreateFile failed"));
-
- OVERLAPPED overlapped;
- ZeroMemory(&overlapped, sizeof(overlapped));
- overlapped.hEvent = ::CreateEvent(NULL, TRUE, FALSE, NULL);
- if (!overlapped.hEvent)
- boost::throw_exception(boost::system::system_error(::GetLastError(), boost::system::system_category, "boost::process::detail::pipe::pipe: CreateEvent failed"));
- BOOL b = ::ConnectNamedPipe(hs[0], &overlapped);
- if (!b){
- if (::GetLastError() == ERROR_IO_PENDING){
- if (::WaitForSingleObject(overlapped.hEvent, INFINITE) == WAIT_FAILED){
- ::CloseHandle(overlapped.hEvent);
- boost::throw_exception(boost::system::system_error(::GetLastError(), boost::system::system_category, "boost::process::detail::pipe::pipe: WaitForSingleObject failed"));
- }
- }
- else if (::GetLastError() != ERROR_PIPE_CONNECTED){
- ::CloseHandle(overlapped.hEvent);
- boost::throw_exception(boost::system::system_error(::GetLastError(), boost::system::system_category, "boost::process::detail::pipe::pipe: ConnectNamedPipe failed"));
- }
- }
- ::CloseHandle(overlapped.hEvent);
- #else
- if (!::CreatePipe(&hs[0], &hs[1], &sa, 0))
- boost::throw_exception(boost::system::system_error(::GetLastError(), boost::system::system_category, "boost::process::detail::pipe::pipe: CreatePipe failed"));
- # endif
- #endif
-
- read_end_ = file_handle(hs[0]);
- write_end_ = file_handle(hs[1]);
- }
-
- /**
- * Returns the %pipe's read end file handle.
- *
- * Obtains a reference to the %pipe's read end file handle. Care
- * should be taken to not duplicate the returned object if ownership
- * shall remain to the %pipe.
- *
- * Duplicating the returned object invalidates its corresponding file
- * handle in the %pipe.
- *
- * \return A reference to the %pipe's read end file handle.
- */
- file_handle &rend()
- {
- return read_end_;
- }
-
- /**
- * Returns the %pipe's write end file handle.
- *
- * Obtains a reference to the %pipe's write end file handle. Care
- * should be taken to not duplicate the returned object if ownership
- * shall remain to the %pipe.
- *
- * Duplicating the returned object invalidates its corresponding file
- * handle in the %pipe.
- *
- * \return A reference to the %pipe's write end file handle.
- */
- file_handle &wend()
- {
- return write_end_;
- }
-
-private:
- /**
- * The %pipe's read end file handle.
- */
- file_handle read_end_;
-
- /**
- * The %pipe's write end file handle.
- */
- file_handle write_end_;
-};
-
-}
-}
-}
+//
+// 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)
+//
+
+/**
+ * \file boost/process/detail/pipe.hpp
+ *
+ * Includes the declaration of the pipe class. This file is for
+ * internal usage only and must not be included by the library user.
+ */
+
+#ifndef BOOST_PROCESS_DETAIL_PIPE_HPP
+#define BOOST_PROCESS_DETAIL_PIPE_HPP
+
+#include <boost/process/config.hpp>
+
+#if defined(BOOST_POSIX_API)
+# include <unistd.h>
+# include <cerrno>
+#elif defined(BOOST_WINDOWS_API)
+# if defined(BOOST_PROCESS_WINDOWS_USE_NAMED_PIPE)
+# include <boost/lexical_cast.hpp>
+# include <string>
+# endif
+# include <windows.h>
+#else
+# error "Unsupported platform."
+#endif
+
+#include <boost/process/detail/file_handle.hpp>
+#include <boost/system/system_error.hpp>
+#include <boost/throw_exception.hpp>
+
+namespace boost
+{
+namespace process
+{
+namespace detail
+{
+
+/**
+ * Simple RAII model for anonymous pipes.
+ *
+ * The pipe class is a simple RAII model for anonymous pipes. It
+ * provides a portable constructor that allocates a new %pipe and creates
+ * a pipe object that owns the two file handles associated to it: the
+ * read end and the write end.
+ *
+ * These handles can be retrieved for modification according to
+ * file_handle semantics. Optionally, their ownership can be transferred
+ * to external \a file_handle objects which comes handy when the two
+ * ends need to be used in different places (i.e. after a POSIX fork()
+ * system call).
+ *
+ * Pipes can be copied following the same semantics as file handles.
+ * In other words, copying a %pipe object invalidates the source one.
+ *
+ * \see file_handle
+ */
+class pipe
+{
+public:
+ /**
+ * Creates a new %pipe.
+ *
+ * The default pipe constructor allocates a new anonymous %pipe
+ * and assigns its ownership to the created pipe object. On Windows
+ * when the macro BOOST_PROCESS_WINDOWS_USE_NAMED_PIPE is defined
+ * a named pipe is created. This is required if asynchronous I/O
+ * should be used as asynchronous I/O is only supported by named
+ * pipes on Windows.
+ *
+ * \throw boost::system::system_error If the anonymous %pipe
+ * creation fails.
+ */
+ pipe()
+ {
+ file_handle::handle_type hs[2];
+
+#if defined(BOOST_POSIX_API)
+ if (::pipe(hs) == -1)
+ boost::throw_exception(boost::system::system_error(
+ boost::system::error_code(
+ errno, boost::system::get_system_category()),
+ "boost::process::detail::pipe::pipe: pipe(2) failed"));
+#elif defined(BOOST_WINDOWS_API)
+
+ SECURITY_ATTRIBUTES sa;
+ ZeroMemory(&sa, sizeof(sa));
+ sa.nLength = sizeof(sa);
+
+ sa.lpSecurityDescriptor = NULL;
+ sa.bInheritHandle = TRUE;
+
+#if defined(BOOST_PROCESS_WINDOWS_USE_NAMED_PIPE)
+ static unsigned int nextid = 0;
+ std::string pipe = "\\\\.\\pipe\\boost_process_" +
+ boost::lexical_cast<std::string>(::GetCurrentProcessId()) + "_"
+ + boost::lexical_cast<std::string>(nextid++);
+ hs[0] = ::CreateNamedPipeA(pipe.c_str(), PIPE_ACCESS_INBOUND |
+ FILE_FLAG_OVERLAPPED, 0, 1, 8192, 8192, 0, &sa);
+ if (hs[0] == INVALID_HANDLE_VALUE)
+ boost::throw_exception(boost::system::system_error(::GetLastError(),
+ boost::system::system_category,
+ "boost::process::detail::pipe::pipe:\
+ CreateNamedPipe failed"));
+ hs[1] = ::CreateFileA(pipe.c_str(), GENERIC_WRITE, 0, NULL,\
+ OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
+ if (hs[1] == INVALID_HANDLE_VALUE)
+ boost::throw_exception(boost::system::system_error(::GetLastError(),\
+ boost::system::system_category,
+ "boost::process::detail::pipe::pipe: CreateFile failed"));
+
+ OVERLAPPED overlapped;
+ ZeroMemory(&overlapped, sizeof(overlapped));
+ overlapped.hEvent = ::CreateEvent(NULL, TRUE, FALSE, NULL);
+ if (!overlapped.hEvent)
+ boost::throw_exception(boost::system::system_error(::GetLastError(),
+ boost::system::system_category,
+ "boost::process::detail::pipe::pipe: CreateEvent failed"));
+ BOOL b = ::ConnectNamedPipe(hs[0], &overlapped);
+ if (!b)
+ {
+ if (::GetLastError() == ERROR_IO_PENDING)
+ {
+ if (::WaitForSingleObject(overlapped.hEvent, INFINITE)
+ == WAIT_FAILED)
+ {
+ ::CloseHandle(overlapped.hEvent);
+ boost::throw_exception(boost::system::system_error(
+ ::GetLastError(),
+ boost::system::system_category,
+ "boost::process::detail::pipe::pipe:\
+ WaitForSingleObject failed"));
+ }
+ }
+ else if (::GetLastError() != ERROR_PIPE_CONNECTED)
+ {
+ ::CloseHandle(overlapped.hEvent);
+ boost::throw_exception(boost::system::system_error(
+ ::GetLastError(), boost::system::system_category,
+ "boost::process::detail::pipe::pipe:\
+ ConnectNamedPipe failed"));
+ }
+ }
+ ::CloseHandle(overlapped.hEvent);
+#else
+ if (!::CreatePipe(&hs[0], &hs[1], &sa, 0))
+ boost::throw_exception(boost::system::system_error(::GetLastError(),
+ boost::system::system_category,
+ "boost::process::detail::pipe::pipe: CreatePipe failed"));
+# endif
+#endif
+
+ read_end_ = file_handle(hs[0]);
+ write_end_ = file_handle(hs[1]);
+ }
+
+ /**
+ * Returns the %pipe's read end file handle.
+ *
+ * Obtains a reference to the %pipe's read end file handle. Care
+ * should be taken to not duplicate the returned object if ownership
+ * shall remain to the %pipe.
+ *
+ * Duplicating the returned object invalidates its corresponding file
+ * handle in the %pipe.
+ *
+ * \return A reference to the %pipe's read end file handle.
+ */
+ file_handle &rend()
+ {
+ return read_end_;
+ }
+
+ /**
+ * Returns the %pipe's write end file handle.
+ *
+ * Obtains a reference to the %pipe's write end file handle. Care
+ * should be taken to not duplicate the returned object if ownership
+ * shall remain to the %pipe.
+ *
+ * Duplicating the returned object invalidates its corresponding file
+ * handle in the %pipe.
+ *
+ * \return A reference to the %pipe's write end file handle.
+ */
+ file_handle &wend()
+ {
+ return write_end_;
+ }
+
+private:
+ /**
+ * The %pipe's read end file handle.
+ */
+ file_handle read_end_;
+
+ /**
+ * The %pipe's write end file handle.
+ */
+ file_handle write_end_;
+};
+
+}
+}
+}
 
-#endif
+#endif

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-05-27 23:09:55 EDT (Thu, 27 May 2010)
@@ -1,29 +1,29 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
+//
+// Boost.Process
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2006, 2007 Julio M. Merino Vidal
+// Copyright (c) 2008, 2009 Boris Schaeling
 // Copyright (c) 2010 Boris Schaeling, Felipe Tanus
-//
-// 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/detail/posix_helper.hpp
- *
- * Includes the declaration of helper functions for the operations in a posix system.
- * It's for internal purposes.
- *
- */
-
-
-#if defined(BOOST_POSIX_API)
- #include <unistd.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <stdio.h>
+//
+// 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/detail/posix_helper.hpp
+ *
+ * Includes the declaration of helper functions for the operations in a posix
+ * system. It's for internal purposes.
+ *
+ */
+
+
+#if defined(BOOST_POSIX_API)
+#include <unistd.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
 #endif
 #include <map>
 #include <string.h>
@@ -32,11 +32,14 @@
 #include <boost/process/detail/stream_detail.hpp>
 
 
-#ifndef BOOST_PROCESS_POSIX_HELPERS_HPP
+#ifndef BOOST_PROCESS_POSIX_HELPERS_HPP
 #define BOOST_PROCESS_POSIX_HELPERS_HPP
-namespace boost{
-namespace process{
-namespace detail{
+namespace boost
+{
+namespace process
+{
+namespace detail
+{
 
 
 
@@ -45,124 +48,137 @@
  * This function, given an stream_detail inherit from the current process
  * father, configure the stream.
  *
- * Note that this function is meant to be called on a brand-new child.
+ * Note that this function is meant to be called on a brand-new child.
  *
  */
-inline configure_child_posix_stream(stream_detail &s){
+inline configure_child_posix_stream(stream_detail &s)
+{
 
- switch(s.behavior){
- case dummy:{
+ switch(s.behavior)
+ {
+ case dummy:
+ {
+
+ std::string null_file;
+ if(s.stream_type == stdin_type)
+ null_file = "/dev/null";
+ else
+ null_file = "/dev/zero";
+
+ int fd;
+ if(s.stream_type == stdin_type)
+ fd = ::open(null_file.c_str(), O_RDONLY);
+ else
+ fd = ::open(null_file.c_str(), O_WRONLY);
+
+ if (fd == -1)
+ boost::throw_exception(boost::system::system_error(
+ boost::system::error_code(errno,
+ boost::system::get_system_category()),
+ "boost::process::detail::setup_input: open(2) of "
+ + s.object.file_ + " failed"));
+
+ s.object.handle_ = file_handle(fd);
+ s.object.handle_.posix_remap(s.stream_handle);
+ s.object.handle_.release();
+
+ break;
+ }
+
+ case closed:
+ ::close(s.stream_handle);
+ break;
+
+ case inherit:
+ //do nothing since is default?
+ break;
+
+ case capture:
+ if(s.stream_type == stdin_type)
+ {
+ s.object.pipe_.wend().close();
+ s.object.pipe_.rend().posix_remap(s.stream_handle);
+ }
+ else
+ {
+ s.object.pipe_.rend().close();
+ s.object.pipe_.wend().posix_remap(s.stream_handle);
+ }
 
- std::string null_file;
- if(s.stream_type == stdin_type)
- null_file = "/dev/null";
- else
- null_file = "/dev/zero";
-
- int fd;
- if(s.stream_type == stdin_type)
- fd = ::open(null_file.c_str(), O_RDONLY);
- else
- fd = ::open(null_file.c_str(), O_WRONLY);
-
- if (fd == -1)
- boost::throw_exception(boost::system::system_error(boost::system::error_code(errno, boost::system::get_system_category()), "boost::process::detail::setup_input: open(2) of " + s.object.file_ + " failed"));
-
- s.object.handle_ = file_handle(fd);
- s.object.handle_.posix_remap(s.stream_handle);
- s.object.handle_.release();
-
- break;
- }
-
- case closed:
- ::close(s.stream_handle);
- break;
-
- case inherit:
- //do nothing since is default?
- break;
-
- case capture:
- if(s.stream_type == stdin_type){
- s.object.pipe_.wend().close();
- s.object.pipe_.rend().posix_remap(s.stream_handle);
- }
- else{
- s.object.pipe_.rend().close();
- s.object.pipe_.wend().posix_remap(s.stream_handle);
- }
-
- break;
+ break;
 
- default:
- BOOST_ASSERT(false);
- }
+ default:
+ BOOST_ASSERT(false);
+ }
 
 }
 
 
-/**
- * Converts an environment to a char** table as used by execve().
- *
- * Converts the environment's contents to the format used by the
- * execve() system call. The returned char** array is allocated
- * in dynamic memory; the caller must free it when not used any
- * more. Each entry is also allocated in dynamic memory and is a
- * NULL-terminated string of the form var=value; these must also be
- * released by the caller.
- *
- * \return A dynamically allocated char** array that represents
- * the environment's content. Each array entry is a
- * NULL-terminated string of the form var=value.
- */
-inline char ** environment_to_envp( environment_t env){
- char **envp = new char*[env.size() + 1];
-
- unsigned int i = 0;
- for (environment_t::const_iterator it = env.begin(); it != env.end(); ++it){
- std::string s = (*it).first + "=" + (*it).second;
- envp[i] = new char[s.size() + 1];
- ::strncpy(envp[i], s.c_str(), s.size() + 1);
- ++i;
- }
- envp[i] = 0;
- return envp;
-}
-
-/**
- * Converts the command line to an array of C strings.
- *
- * Converts the command line's list of arguments to the format expected
- * by the \a argv parameter in the POSIX execve() system call.
- *
- * This operation is only available on POSIX systems.
- *
- * \return The first argument of the pair is an integer that indicates
- * how many strings are stored in the second argument. The
- * second argument is a NULL-terminated, dynamically allocated
- * array of dynamically allocated strings holding the arguments
- * to the executable. The caller is responsible of freeing them.
- */
-template <class Arguments>
-inline std::pair<std::size_t, char**> collection_to_posix_argv(const Arguments &args)
-{
- std::size_t nargs = args.size();
- BOOST_ASSERT(nargs >= 0);
-
- char **argv = new char*[nargs + 1];
- typename Arguments::size_type i = 0;
- for (typename Arguments::const_iterator it = args.begin(); it != args.end(); ++it)
- {
- argv[i] = new char[it->size() + 1];
- ::strncpy(argv[i], it->c_str(), it->size() + 1);
- ++i;
- }
- argv[nargs] = 0;
-
- return std::pair<std::size_t, char**>(nargs, argv);
-}
-
+/**
+ * Converts an environment to a char** table as used by execve().
+ *
+ * Converts the environment's contents to the format used by the
+ * execve() system call. The returned char** array is allocated
+ * in dynamic memory; the caller must free it when not used any
+ * more. Each entry is also allocated in dynamic memory and is a
+ * NULL-terminated string of the form var=value; these must also be
+ * released by the caller.
+ *
+ * \return A dynamically allocated char** array that represents
+ * the environment's content. Each array entry is a
+ * NULL-terminated string of the form var=value.
+ */
+inline char ** environment_to_envp( environment_t env)
+{
+ char **envp = new char*[env.size() + 1];
+
+ unsigned int i = 0;
+ for (environment_t::const_iterator it = env.begin(); it != env.end(); ++it)
+ {
+ std::string s = (*it).first + "=" + (*it).second;
+ envp[i] = new char[s.size() + 1];
+ ::strncpy(envp[i], s.c_str(), s.size() + 1);
+ ++i;
+ }
+ envp[i] = 0;
+ return envp;
+}
+
+/**
+ * Converts the command line to an array of C strings.
+ *
+ * Converts the command line's list of arguments to the format expected
+ * by the \a argv parameter in the POSIX execve() system call.
+ *
+ * This operation is only available on POSIX systems.
+ *
+ * \return The first argument of the pair is an integer that indicates
+ * how many strings are stored in the second argument. The
+ * second argument is a NULL-terminated, dynamically allocated
+ * array of dynamically allocated strings holding the arguments
+ * to the executable. The caller is responsible of freeing them.
+ */
+template <class Arguments>
+inline std::pair<std::size_t, char**> collection_to_posix_argv(const Arguments
+ &args)
+{
+ std::size_t nargs = args.size();
+ BOOST_ASSERT(nargs >= 0);
+
+ char **argv = new char*[nargs + 1];
+ typename Arguments::size_type i = 0;
+ for (typename Arguments::const_iterator it = args.begin();
+ it != args.end(); ++it)
+ {
+ argv[i] = new char[it->size() + 1];
+ ::strncpy(argv[i], it->c_str(), it->size() + 1);
+ ++i;
+ }
+ argv[nargs] = 0;
+
+ return std::pair<std::size_t, char**>(nargs, argv);
+}
+
 }
 }
 }

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-05-27 23:09:55 EDT (Thu, 27 May 2010)
@@ -1,24 +1,24 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
+//
+// Boost.Process
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2006, 2007 Julio M. Merino Vidal
+// Copyright (c) 2008, 2009 Boris Schaeling
 // Copyright (c) 2010 Boris Schaeling, Felipe Tanus
-//
-// 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/detail/stream_detail.hpp
- *
+//
+// 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/detail/stream_detail.hpp
+ *
  * Includes the declaration of the stream_detail struct.
  * It's for internal purposes
  *
- */
+ */
 
-#include <boost/process/config.hpp>
+#include <boost/process/config.hpp>
 #include <map>
 #include <boost/optional.hpp>
 #include <boost/process/stream_behavior.hpp>
@@ -27,25 +27,29 @@
 
 
 
-#ifndef BOOST_PROCESS_STREAM_DETAIL_HPP
-#define BOOST_PROCESS_STREAM_DETAIL_HPP
-namespace boost{
-namespace process{
-namespace detail{
+#ifndef BOOST_PROCESS_STREAM_DETAIL_HPP
+#define BOOST_PROCESS_STREAM_DETAIL_HPP
+namespace boost
+{
+namespace process
+{
+namespace detail
+{
 
 
-/*
+/*
  * This is the declaration of stream_object.
  * It represents all types that can be assign of an stream object
  * representation. For example, it can point to another stream or
  * to a pipe.
  */
 
-struct stream_object {
- int desc_to;
- std::string file_;
- file_handle handle_;
- pipe pipe_;
+struct stream_object
+{
+ int desc_to;
+ std::string file_;
+ file_handle handle_;
+ pipe pipe_;
 };
 
 
@@ -66,59 +70,66 @@
  * stream_type: Defines if the stream is a stdin, out or error.
  * behavior: The behavior this stream will assume
  * object: The object required to this behavior (see stream_object above)
- *
+ *
  */
 
-struct stream_detail {
+struct stream_detail
+{
 
- #if defined(BOOST_POSIX_API)
- int stream_handle;
- #elif defined(BOOST_WINDOWS_API)
- DWORD stream_handle;
- #endif
-
- struct stream_object object;
- std_stream_type stream_type;
- stream_behavior behavior;
-
- stream_detail(std_stream_type st){
- stream_type = st;
- object.pipe_ = pipe();
- switch(st){
- case stdin_type:{
-
- #if defined(BOOST_POSIX_API)
- stream_handle = STDIN_FILENO;
- #elif defined(BOOST_WINDOWS_API)
- stream_handle = STD_INPUT_HANDLE;
- #endif
- break;
- }
- case stdout_type:{
- #if defined(BOOST_POSIX_API)
- stream_handle = STDOUT_FILENO;
- #elif defined(BOOST_WINDOWS_API)
- stream_handle = STD_OUTPUT_HANDLE;
- #endif
- break;
- }
- case stderr_type:{
- #if defined(BOOST_POSIX_API)
- stream_handle = STDERR_FILENO;
- #elif defined(BOOST_WINDOWS_API)
- stream_handle = STD_ERROR_HANDLE;
- #endif
- break;
- }
- default:{
+#if defined(BOOST_POSIX_API)
+ int stream_handle;
+#elif defined(BOOST_WINDOWS_API)
+ DWORD stream_handle;
+#endif
 
- BOOST_ASSERT(false);
- }
+ struct stream_object object;
+ std_stream_type stream_type;
+ stream_behavior behavior;
+
+ stream_detail(std_stream_type st)
+ {
+ stream_type = st;
+ object.pipe_ = pipe();
+ switch(st)
+ {
+ case stdin_type:
+ {
+
+#if defined(BOOST_POSIX_API)
+ stream_handle = STDIN_FILENO;
+#elif defined(BOOST_WINDOWS_API)
+ stream_handle = STD_INPUT_HANDLE;
+#endif
+ break;
+ }
+ case stdout_type:
+ {
+#if defined(BOOST_POSIX_API)
+ stream_handle = STDOUT_FILENO;
+#elif defined(BOOST_WINDOWS_API)
+ stream_handle = STD_OUTPUT_HANDLE;
+#endif
+ break;
+ }
+ case stderr_type:
+ {
+#if defined(BOOST_POSIX_API)
+ stream_handle = STDERR_FILENO;
+#elif defined(BOOST_WINDOWS_API)
+ stream_handle = STD_ERROR_HANDLE;
+#endif
+ break;
+ }
+ default:
+ {
 
+ BOOST_ASSERT(false);
+ }
 
- }
 
         }
+
+ }
 };
 
 

Modified: sandbox/SOC/2010/process/boost/process/detail/systembuf.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/detail/systembuf.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/detail/systembuf.hpp 2010-05-27 23:09:55 EDT (Thu, 27 May 2010)
@@ -1,52 +1,55 @@
-//
-// 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)
-//
-
-/**
- * \file boost/process/detail/systembuf.hpp
- *
- * Includes the declaration of the systembuf class. This file is for
- * internal usage only and must not be included by the library user.
- */
+//
+// 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)
+//
 
-#ifndef BOOST_PROCESS_DETAIL_SYSTEMBUF_HPP
-#define BOOST_PROCESS_DETAIL_SYSTEMBUF_HPP
+/**
+ * \file boost/process/detail/systembuf.hpp
+ *
+ * Includes the declaration of the systembuf class. This file is for
+ * internal usage only and must not be included by the library user.
+ */
+
+#ifndef BOOST_PROCESS_DETAIL_SYSTEMBUF_HPP
+#define BOOST_PROCESS_DETAIL_SYSTEMBUF_HPP
 
 #include <boost/process/config.hpp>
 
 #if defined(BOOST_POSIX_API)
- #include <sys/types.h>
- #include <unistd.h>
+#include <sys/types.h>
+#include <unistd.h>
 
 #elif defined(BOOST_WINDOWS_API)
- #include <windows.h>
-#else
- #error "Unsupported platform."
-#endif
+#include <windows.h>
+#else
+#error "Unsupported platform."
+#endif
+
+#include <boost/noncopyable.hpp>
+#include <boost/scoped_array.hpp>
+#include <boost/assert.hpp>
+#include <streambuf>
+#include <cstddef>
+
+namespace boost
+{
+namespace process
+{
 
-#include <boost/noncopyable.hpp>
-#include <boost/scoped_array.hpp>
-#include <boost/assert.hpp>
-#include <streambuf>
-#include <cstddef>
+class postream;
 
-namespace boost {
-namespace process {
+namespace detail
+{
 
-class postream;
-
-namespace detail {
-
-/**
+/**
  * std::streambuf implementation for system file handles.
- *
+ *
  * systembuf provides a std::streambuf implementation for system file
  * handles. Contrarywise to file_handle, this class does \b not take
  * ownership of the native file handle; this should be taken care of
@@ -56,177 +59,185 @@
  * However, it is not copyable to avoid introducing inconsistences with
  * the on-disk file and the in-memory buffers.
  */
-class systembuf : public std::streambuf, public boost::noncopyable {
+class systembuf : public std::streambuf, public boost::noncopyable
+{
 
- friend class ::boost::process::postream;
+ friend class ::boost::process::postream;
 
 public:
- #if defined(BOOST_PROCESS_DOXYGEN)
- /**
- * Opaque name for the native handle type.
- */
- typedef NativeHandleType handle_type;
- #elif defined(BOOST_POSIX_API)
- typedef int handle_type;
- #elif defined(BOOST_WINDOWS_API)
- typedef HANDLE handle_type;
- #endif
-
- /**
- * Constructs a new systembuf for the given file handle.
- *
- * This constructor creates a new systembuf object that reads or
- * writes data from/to the \a h native file handle. This handle
- * is \b not owned by the created systembuf object; the code
- * should take care of it externally.
- *
- * This class buffers input and output; the buffer size may be
- * tuned through the \a bufsize parameter, which defaults to 8192
- * bytes.
- *
- * \see pistream and postream
- */
-
- explicit systembuf(handle_type h, std::size_t bufsize = 8192)
- : handle_(h),
- bufsize_(bufsize),
- read_buf_(new char[bufsize]),
- write_buf_(new char[bufsize]){
- #if defined(BOOST_POSIX_API)
- BOOST_ASSERT(handle_ >= 0);
- #elif defined(BOOST_WINDOWS_API)
- BOOST_ASSERT(handle_ != INVALID_HANDLE_VALUE);
- #endif
+#if defined(BOOST_PROCESS_DOXYGEN)
+ /**
+ * Opaque name for the native handle type.
+ */
+ typedef NativeHandleType handle_type;
+#elif defined(BOOST_POSIX_API)
+ typedef int handle_type;
+#elif defined(BOOST_WINDOWS_API)
+ typedef HANDLE handle_type;
+#endif
+
+ /**
+ * Constructs a new systembuf for the given file handle.
+ *
+ * This constructor creates a new systembuf object that reads or
+ * writes data from/to the \a h native file handle. This handle
+ * is \b not owned by the created systembuf object; the code
+ * should take care of it externally.
+ *
+ * This class buffers input and output; the buffer size may be
+ * tuned through the \a bufsize parameter, which defaults to 8192
+ * bytes.
+ *
+ * \see pistream and postream
+ */
+
+ explicit systembuf(handle_type h, std::size_t bufsize = 8192)
+ : handle_(h),
+ bufsize_(bufsize),
+ read_buf_(new char[bufsize]),
+ write_buf_(new char[bufsize])
+ {
+#if defined(BOOST_POSIX_API)
+ BOOST_ASSERT(handle_ >= 0);
+#elif defined(BOOST_WINDOWS_API)
+ BOOST_ASSERT(handle_ != INVALID_HANDLE_VALUE);
+#endif
         BOOST_ASSERT(bufsize_ > 0);
 
         setp(write_buf_.get(), write_buf_.get() + bufsize_);
- }
+ }
 
 protected:
- /**
- * Reads new data from the native file handle.
- *
- * This operation is called by input methods when there is no more
- * data in the input buffer. The function fills the buffer with new
- * data, if available.
- *
- * \pre All input positions are exhausted (gptr() >= egptr()).
- * \post The input buffer has new data, if available.
- * \returns traits_type::eof() if a read error occurrs or there are
- * no more data to be read. Otherwise returns
- * traits_type::to_int_type(*gptr()).
- */
- virtual int_type underflow(){
- BOOST_ASSERT(gptr() >= egptr());
-
- bool ok;
- #if defined(BOOST_POSIX_API)
- ssize_t cnt = ::read(handle_, read_buf_.get(), bufsize_);
- ok = (cnt != -1 && cnt != 0);
- #elif defined(BOOST_WINDOWS_API)
- DWORD cnt;
- BOOL res = ::ReadFile(handle_, read_buf_.get(), bufsize_, &cnt, NULL);
- ok = (res && cnt > 0);
- #endif
-
- if (!ok)
- return traits_type::eof();
- else{
- setg(read_buf_.get(), read_buf_.get(), read_buf_.get() + cnt);
- return traits_type::to_int_type(*gptr());
- }
- }
+ /**
+ * Reads new data from the native file handle.
+ *
+ * This operation is called by input methods when there is no more
+ * data in the input buffer. The function fills the buffer with new
+ * data, if available.
+ *
+ * \pre All input positions are exhausted (gptr() >= egptr()).
+ * \post The input buffer has new data, if available.
+ * \returns traits_type::eof() if a read error occurrs or there are
+ * no more data to be read. Otherwise returns
+ * traits_type::to_int_type(*gptr()).
+ */
+ virtual int_type underflow()
+ {
+ BOOST_ASSERT(gptr() >= egptr());
 
- /**
- * Makes room in the write buffer for additional data.
- *
- * This operation is called by output methods when there is no more
- * space in the output buffer to hold a new element. The function
- * first flushes the buffer's contents to disk and then clears it to
- * leave room for more characters. The given \a c character is
- * stored at the beginning of the new space.
- *
- * \pre All output positions are exhausted (pptr() >= epptr()).
- * \post The output buffer has more space if no errors occurred
- * during the write to disk.
- * \post *(pptr() - 1) is \a c.
- * \returns traits_type::eof() if a write error occurrs. Otherwise
- * returns traits_type::not_eof(c).
- */
- int_type overflow(int c){
- BOOST_ASSERT(pptr() >= epptr());
-
- if (sync() == -1)
- return traits_type::eof();
-
- if (!traits_type::eq_int_type(c, traits_type::eof())){
- traits_type::assign(*pptr(), c);
- pbump(1);
- }
-
- return traits_type::not_eof(c);
- }
-
- /**
- * Flushes the output buffer to disk.
- *
- * Synchronizes the systembuf buffers with the contents of the file
- * associated to this object through the native file handle. The
- * output buffer is flushed to disk and cleared to leave new room
- * for more data.
- *
- * \returns 0 on success, -1 if an error occurred.
- */
-
-
- #if defined(BOOST_POSIX_API)
- virtual int sync(){
- ssize_t cnt = pptr() - pbase();
- bool ok;
-
- ok = (::write(handle_, pbase(), cnt) == cnt);
- if (ok)
- pbump(-cnt);
- return ok ? 0 : -1;
+ bool ok;
+#if defined(BOOST_POSIX_API)
+ ssize_t cnt = ::read(handle_, read_buf_.get(), bufsize_);
+ ok = (cnt != -1 && cnt != 0);
+#elif defined(BOOST_WINDOWS_API)
+ DWORD cnt;
+ BOOL res = ::ReadFile(handle_, read_buf_.get(), bufsize_, &cnt, NULL);
+ ok = (res && cnt > 0);
+#endif
+
+ if (!ok)
+ return traits_type::eof();
+ else
+ {
+ setg(read_buf_.get(), read_buf_.get(), read_buf_.get() + cnt);
+ return traits_type::to_int_type(*gptr());
         }
- #elif defined(BOOST_WINDOWS_API)
- virtual int sync(){
- long cnt = pptr() - pbase();
- bool ok;
- DWORD rcnt;
- BOOL res = ::WriteFile(handle_, pbase(), cnt, &rcnt, NULL);
-
- ok = (res && static_cast<long>(rcnt) == cnt);
- if (ok)
- pbump(-cnt);
- return ok ? 0 : -1;
+ }
+
+ /**
+ * Makes room in the write buffer for additional data.
+ *
+ * This operation is called by output methods when there is no more
+ * space in the output buffer to hold a new element. The function
+ * first flushes the buffer's contents to disk and then clears it to
+ * leave room for more characters. The given \a c character is
+ * stored at the beginning of the new space.
+ *
+ * \pre All output positions are exhausted (pptr() >= epptr()).
+ * \post The output buffer has more space if no errors occurred
+ * during the write to disk.
+ * \post *(pptr() - 1) is \a c.
+ * \returns traits_type::eof() if a write error occurrs. Otherwise
+ * returns traits_type::not_eof(c).
+ */
+ int_type overflow(int c)
+ {
+ BOOST_ASSERT(pptr() >= epptr());
+
+ if (sync() == -1)
+ return traits_type::eof();
+
+ if (!traits_type::eq_int_type(c, traits_type::eof()))
+ {
+ traits_type::assign(*pptr(), c);
+ pbump(1);
         }
- #endif
+
+ return traits_type::not_eof(c);
+ }
+
+ /**
+ * Flushes the output buffer to disk.
+ *
+ * Synchronizes the systembuf buffers with the contents of the file
+ * associated to this object through the native file handle. The
+ * output buffer is flushed to disk and cleared to leave new room
+ * for more data.
+ *
+ * \returns 0 on success, -1 if an error occurred.
+ */
+
+
+#if defined(BOOST_POSIX_API)
+ virtual int sync()
+ {
+ ssize_t cnt = pptr() - pbase();
+ bool ok;
+
+ ok = (::write(handle_, pbase(), cnt) == cnt);
+ if (ok)
+ pbump(-cnt);
+ return ok ? 0 : -1;
+ }
+#elif defined(BOOST_WINDOWS_API)
+ virtual int sync()
+ {
+ long cnt = pptr() - pbase();
+ bool ok;
+ DWORD rcnt;
+ BOOL res = ::WriteFile(handle_, pbase(), cnt, &rcnt, NULL);
+
+ ok = (res && static_cast<long>(rcnt) == cnt);
+ if (ok)
+ pbump(-cnt);
+ return ok ? 0 : -1;
+ }
+#endif
 
 private:
- /**
- * Native file handle used by the systembuf object.
- */
- handle_type handle_;
-
- /**
- * Internal buffer size used during read and write operations.
- */
- std::size_t bufsize_;
-
- /**
- * Internal buffer used during read operations.
- */
- boost::scoped_array<char> read_buf_;
-
- /**
- * Internal buffer used during write operations.
- */
- boost::scoped_array<char> write_buf_;
+ /**
+ * Native file handle used by the systembuf object.
+ */
+ handle_type handle_;
+
+ /**
+ * Internal buffer size used during read and write operations.
+ */
+ std::size_t bufsize_;
+
+ /**
+ * Internal buffer used during read operations.
+ */
+ boost::scoped_array<char> read_buf_;
+
+ /**
+ * Internal buffer used during write operations.
+ */
+ boost::scoped_array<char> write_buf_;
 };
 
 }
 }
 }
 
-#endif
+#endif

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-05-27 23:09:55 EDT (Thu, 27 May 2010)
@@ -1,206 +1,228 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
+//
+// Boost.Process
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2006, 2007 Julio M. Merino Vidal
+// Copyright (c) 2008, 2009 Boris Schaeling
 // Copyright (c) 2010 Boris Schaeling, Felipe Tanus
-//
-// 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/detail/helper_functions.hpp
- *
- * Includes the declaration of helper functions for the operations in a win32 system.
- * It's for internal purposes.
- *
- */
-
-#include <boost/process/detail/file_handle.hpp>
-#include <boost/process/detail/stream_detail.hpp>
-#include <boost/process/detail/pipe.hpp>
-#include <boost/process/child.hpp>
-#include <boost/scoped_ptr.hpp>
-#include <boost/shared_array.hpp>
-#include <boost/scoped_array.hpp>
-#include <boost/assert.hpp>
-#include <boost/system/system_error.hpp>
-#include <boost/throw_exception.hpp>
-#include <vector>
-#include <map>
-#include <string>
-#include <cstddef>
-#include <string.h>
-#include <windows.h>
+//
+// 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/detail/helper_functions.hpp
+ *
+ * Includes the declaration of helper functions for the operations in a win32
+ * system. It's for internal purposes.
+ *
+ */
+
+#include <boost/process/detail/file_handle.hpp>
+#include <boost/process/detail/stream_detail.hpp>
+#include <boost/process/detail/pipe.hpp>
+#include <boost/process/child.hpp>
+#include <boost/scoped_ptr.hpp>
+#include <boost/shared_array.hpp>
+#include <boost/scoped_array.hpp>
+#include <boost/assert.hpp>
+#include <boost/system/system_error.hpp>
+#include <boost/throw_exception.hpp>
+#include <vector>
+#include <map>
+#include <string>
+#include <cstddef>
+#include <string.h>
+#include <windows.h>
 
 
 
-#ifndef BOOST_PROCESS_WIN32_HELPERS_HPP
+#ifndef BOOST_PROCESS_WIN32_HELPERS_HPP
 #define BOOST_PROCESS_WIN32_HELPERS_HPP
-namespace boost{
-namespace process{
-namespace detail{
-
-/**
- * Converts an environment to a string used by CreateProcess().
- *
- * Converts the environment's contents to the format used by the
- * CreateProcess() system call. The returned char* string is
- * allocated in dynamic memory; the caller must free it when not
- * used any more. This is enforced by the use of a shared pointer.
- *
- * \return A dynamically allocated char* string that represents
- * the environment's content. This string is of the form
- * var1=value1\\0var2=value2\\0\\0.
- */
-inline boost::shared_array<char> environment_to_win32_strings(environment_t &env){
- boost::shared_array<char> envp;
-
- if (env.empty())
- {
- envp.reset(new char[2]);
- ::ZeroMemory(envp.get(), 2);
- }
- else
- {
- std::string s;
- for (environment_t::const_iterator it = env.begin(); it != env.end(); ++it)
- {
- s += (*it).first + "=" + (*it).second;
- s.push_back(0);
- }
-
- envp.reset(new char[s.size() + 1]);
-#if defined(__CYGWIN__) || defined(_SCL_SECURE_NO_DEPRECATE)
- ::memcpy(envp.get(), s.c_str(), s.size() + 1);
-#else
- ::memcpy_s(envp.get(), s.size() + 1, s.c_str(), s.size() + 1);
-#endif
- }
-
- return envp;
-}
-
-
-
-/**
- * Converts the command line to a plain string. Converts the command line's
- * list of arguments to the format expected by the \a lpCommandLine parameter
- * in the CreateProcess() system call.
- *
- * This operation is only available on Windows systems.
- *
- * \return A dynamically allocated string holding the command line
- * to be passed to the executable. It is returned in a
- * shared_array object to ensure its release at some point.
- */
-template <class Arguments>
-inline boost::shared_array<char> collection_to_win32_cmdline(const Arguments &args){
- typedef std::vector<std::string> arguments_t;
- arguments_t args2;
- typename Arguments::size_type i = 0;
- std::size_t size = 0;
- for (typename Arguments::const_iterator it = args.begin(); it != args.end(); ++it)
- {
- std::string arg = *it;
-
- std::string::size_type pos = 0;
- while ( (pos = arg.find('"', pos)) != std::string::npos)
- {
- arg.replace(pos, 1, "\\\"");
- pos += 2;
- }
-
- if (arg.find(' ') != std::string::npos)
- arg = '\"' + arg + '\"';
-
- if (i++ != args.size() - 1)
- arg += ' ';
-
- args2.push_back(arg);
- size += arg.size() + 1;
- }
-
- boost::shared_array<char> cmdline(new char[size]);
- cmdline.get()[0] = '\0';
- for (arguments_t::size_type i = 0; i < args.size(); ++i)
-#if defined(__CYGWIN__) || defined(_SCL_SECURE_NO_DEPRECATE)
- ::strncat(cmdline.get(), args2[i].c_str(), args2[i].size());
-#else
- ::strcat_s(cmdline.get(), size, args2[i].c_str());
-#endif
+namespace boost
+{
+namespace process
+{
+namespace detail
+{
+
+/**
+ * Converts an environment to a string used by CreateProcess().
+ *
+ * Converts the environment's contents to the format used by the
+ * CreateProcess() system call. The returned char* string is
+ * allocated in dynamic memory; the caller must free it when not
+ * used any more. This is enforced by the use of a shared pointer.
+ *
+ * \return A dynamically allocated char* string that represents
+ * the environment's content. This string is of the form
+ * var1=value1\\0var2=value2\\0\\0.
+ */
+inline boost::shared_array<char>environment_to_win32_strings(environment_t &env)
+{
+ boost::shared_array<char> envp;
+
+ if (env.empty())
+ {
+ envp.reset(new char[2]);
+ ::ZeroMemory(envp.get(), 2);
+ }
+ else
+ {
+ std::string s;
+ for (environment_t::const_iterator it = env.begin();
+ it != env.end(); ++it)
+ {
+ s += (*it).first + "=" + (*it).second;
+ s.push_back(0);
+ }
+
+ envp.reset(new char[s.size() + 1]);
+#if defined(__CYGWIN__) || defined(_SCL_SECURE_NO_DEPRECATE)
+ ::memcpy(envp.get(), s.c_str(), s.size() + 1);
+#else
+ ::memcpy_s(envp.get(), s.size() + 1, s.c_str(), s.size() + 1);
+#endif
+ }
+
+ return envp;
+}
+
+
+
+/**
+ * Converts the command line to a plain string. Converts the command line's
+ * list of arguments to the format expected by the \a lpCommandLine parameter
+ * in the CreateProcess() system call.
+ *
+ * This operation is only available on Windows systems.
+ *
+ * \return A dynamically allocated string holding the command line
+ * to be passed to the executable. It is returned in a
+ * shared_array object to ensure its release at some point.
+ */
+template <class Arguments>
+inline boost::shared_array<char> collection_to_win32_cmdline(const Arguments
+ &args)
+{
+ typedef std::vector<std::string> arguments_t;
+ arguments_t args2;
+ typename Arguments::size_type i = 0;
+ std::size_t size = 0;
+ for (typename Arguments::const_iterator it = args.begin();
+ it != args.end(); ++it)
+ {
+ std::string arg = *it;
+
+ std::string::size_type pos = 0;
+ while ( (pos = arg.find('"', pos)) != std::string::npos)
+ {
+ arg.replace(pos, 1, "\\\"");
+ pos += 2;
+ }
+
+ if (arg.find(' ') != std::string::npos)
+ arg = '\"' + arg + '\"';
+
+ if (i++ != args.size() - 1)
+ arg += ' ';
+
+ args2.push_back(arg);
+ size += arg.size() + 1;
+ }
+
+ boost::shared_array<char> cmdline(new char[size]);
+ cmdline.get()[0] = '\0';
+ for (arguments_t::size_type i = 0; i < args.size(); ++i)
+#if defined(__CYGWIN__) || defined(_SCL_SECURE_NO_DEPRECATE)
+ ::strncat(cmdline.get(), args2[i].c_str(), args2[i].size());
+#else
+ ::strcat_s(cmdline.get(), size, args2[i].c_str());
+#endif
 
- return cmdline;
-}
+ return cmdline;
+}
 
 /*
  * This function configures the std stream of the new process.
- * It recieves stream_detail from that stream and a STARTUPINFOA
- * That will be stored the configuration.
+ * It recieves stream_detail from that stream and return a file_handle
+ * that contains the handle to the stream.
  */
-inline file_handle configure_win32_stream(stream_detail &sd){
+inline file_handle configure_win32_stream(stream_detail &sd)
+{
+
+ file_handle return_handle;
 
- file_handle return_handle;
+ switch (sd.behavior)
+ {
+ case closed:
+ {
+ return_handle = file_handle();
+ break;
+ }
+ case inherit:
+ {
+ return_handle = file_handle::win32_dup_std(sd.stream_handle, true);
+ break;
+ }
+
+ case dummy:
+ {
+ HANDLE h;
+ if(sd.stream_type == stdin_type)
+ {
+ h = ::CreateFileA("NUL",
+ GENERIC_READ, 0, NULL, OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL, NULL);
+
+ }
+ else
+ {
+ h = ::CreateFileA("NUL",
+ GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL, NULL);
+ }
+
+ if (h == INVALID_HANDLE_VALUE)
+ boost::throw_exception(boost::system::system_error(
+ boost::system::error_code(::GetLastError(),
+ boost::system::get_system_category()),
+ "boost::process::detail::win32_start: CreateFile failed"));
+
+ return_handle = file_handle(h);
+
+ break;
+ }
+
+ case capture:
+ {
+ if(sd.stream_type == stdin_type)
+ {
+ sd.object.pipe_.rend().win32_set_inheritable(true);
+ return_handle = sd.object.pipe_.rend();
+ }
+ else
+ {
+ sd.object.pipe_.wend().win32_set_inheritable(true);
+ return_handle = sd.object.pipe_.wend();
+ }
+
+ break;
+ }
+
+ default:
+ {
+ BOOST_ASSERT(false);
+
+ }
+ }
+
+ return return_handle;
 
- switch (sd.behavior){
- case closed:{
- return_handle = file_handle();
- break;
- }
- case inherit:{
- return_handle = file_handle::win32_dup_std(sd.stream_handle, true);
- break;
- }
-
- case dummy:{
- HANDLE h;
- if(sd.stream_type == stdin_type){
- h = ::CreateFileA("NUL",
- GENERIC_READ, 0, NULL, OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL, NULL);
-
- }
- else{
- h = ::CreateFileA("NUL",
- GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL, NULL);
- }
-
- if (h == INVALID_HANDLE_VALUE)
- boost::throw_exception(boost::system::system_error(boost::system::error_code(::GetLastError(), boost::system::get_system_category()), "boost::process::detail::win32_start: CreateFile failed"));
-
- return_handle = file_handle(h);
-
- break;
- }
-
- case capture:{
- if(sd.stream_type == stdin_type){
- sd.object.pipe_.rend().win32_set_inheritable(true);
- return_handle = sd.object.pipe_.rend();
- }
- else{
- sd.object.pipe_.wend().win32_set_inheritable(true);
- return_handle = sd.object.pipe_.wend();
- }
-
- break;
- }
-
- default:{
- BOOST_ASSERT(false);
-
- }
- }
-
- return return_handle;
-
 
 }
 
-
+
 }
 }
 }

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-05-27 23:09:55 EDT (Thu, 27 May 2010)
@@ -1,50 +1,52 @@
-//
-// 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)
-//
-
-/**
- * \file boost/process/environment.hpp
- *
- * Includes the declaration of the environment class.
- */
-
-#ifndef BOOST_PROCESS_ENVIRONMENT_HPP
-#define BOOST_PROCESS_ENVIRONMENT_HPP
-
-#include <string>
-#include <map>
-
-namespace boost {
-namespace process {
-
-/**
- * Representation of a process' environment variables.
- *
- * The environment is a map that stablishes an unidirectional
- * association between variable names and their values and is
- * represented by a string to string map.
- *
- * Variables may be defined to the empty string. Be aware that doing so
- * is not portable: POSIX systems will treat such variables as being
- * defined to the empty value, but Windows systems are not able to
- * distinguish them from undefined variables.
- *
- * Neither POSIX nor Windows systems support a variable with no name.
- *
- * It is worthy to note that the environment is sorted alphabetically.
- * This is provided for-free by the map container used to implement this
- * type, and this behavior is required by Windows systems.
- */
-typedef std::map<std::string, std::string> environment_t;
+//
+// 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)
+//
+
+/**
+ * \file boost/process/environment.hpp
+ *
+ * Includes the declaration of the environment class.
+ */
+
+#ifndef BOOST_PROCESS_ENVIRONMENT_HPP
+#define BOOST_PROCESS_ENVIRONMENT_HPP
+
+#include <string>
+#include <map>
+
+namespace boost
+{
+namespace process
+{
+
+/**
+ * Representation of a process' environment variables.
+ *
+ * The environment is a map that stablishes an unidirectional
+ * association between variable names and their values and is
+ * represented by a string to string map.
+ *
+ * Variables may be defined to the empty string. Be aware that doing so
+ * is not portable: POSIX systems will treat such variables as being
+ * defined to the empty value, but Windows systems are not able to
+ * distinguish them from undefined variables.
+ *
+ * Neither POSIX nor Windows systems support a variable with no name.
+ *
+ * It is worthy to note that the environment is sorted alphabetically.
+ * This is provided for-free by the map container used to implement this
+ * type, and this behavior is required by Windows systems.
+ */
+typedef std::map<std::string, std::string> environment_t;
 
-}
-}
+}
+}
 
-#endif
+#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-05-27 23:09:55 EDT (Thu, 27 May 2010)
@@ -1,373 +1,389 @@
-//
-// 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)
-//
-
-/**
- * \file boost/process/operations.hpp
- *
- * Provides miscellaneous free functions.
- */
-
-#ifndef BOOST_PROCESS_OPERATIONS_HPP
-#define BOOST_PROCESS_OPERATIONS_HPP
-
-#include <boost/process/config.hpp>
-
-#if defined(BOOST_POSIX_API)
- #include <boost/process/detail/posix_helpers.hpp>
- #include <stdlib.h>
- #include <unistd.h>
- #if defined(__CYGWIN__)
- #include <boost/scoped_array.hpp>
- #include <sys/cygwin.h>
- #endif
-#elif defined(BOOST_WINDOWS_API)
- #include <boost/process/detail/win32_helpers.hpp>
- #include <boost/algorithm/string/predicate.hpp>
- #include <windows.h>
-#else
-# error "Unsupported platform."
-#endif
-
-/*
-#include <boost/process/child.hpp>
-#include <boost/process/stream_behavior.hpp>
-#include <boost/process/status.hpp>
-#include <boost/process/detail/file_handle.hpp>
-#include <boost/process/detail/pipe.hpp>
-#include <boost/process/detail/stream_info.hpp>
-*/
-#include <boost/process/child.hpp>
-#include <boost/process/context.hpp>
-#include <boost/process/stream_behavior.hpp>
-#include <boost/process/status.hpp>
-#include <boost/process/detail/file_handle.hpp>
+//
+// 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)
+//
+
+/**
+ * \file boost/process/operations.hpp
+ *
+ * Provides miscellaneous free functions.
+ */
+
+#ifndef BOOST_PROCESS_OPERATIONS_HPP
+#define BOOST_PROCESS_OPERATIONS_HPP
+
+#include <boost/process/config.hpp>
+
+#if defined(BOOST_POSIX_API)
+#include <boost/process/detail/posix_helpers.hpp>
+#include <stdlib.h>
+#include <unistd.h>
+#if defined(__CYGWIN__)
+#include <boost/scoped_array.hpp>
+#include <sys/cygwin.h>
+#endif
+#elif defined(BOOST_WINDOWS_API)
+#include <boost/process/detail/win32_helpers.hpp>
+#include <boost/algorithm/string/predicate.hpp>
+#include <windows.h>
+#else
+# error "Unsupported platform."
+#endif
+
+#include <boost/process/child.hpp>
+#include <boost/process/context.hpp>
+#include <boost/process/stream_behavior.hpp>
+#include <boost/process/status.hpp>
+#include <boost/process/detail/file_handle.hpp>
 #include <boost/process/detail/stream_detail.hpp>
 
 
-#include <boost/filesystem/path.hpp>
-#include <boost/algorithm/string/predicate.hpp>
-#include <boost/system/system_error.hpp>
-#include <boost/throw_exception.hpp>
-#include <boost/scoped_array.hpp>
-#include <boost/assert.hpp>
-#include <string>
-#include <vector>
-#include <stdexcept>
-#include <cstddef>
-
-
-namespace boost {
-namespace process {
-
-/**
- * Locates the executable program \a file in all the directory components
- * specified in \a path. If \a path is empty, the value of the PATH
- * environment variable is used.
- *
- * The path variable is interpreted following the same conventions used
- * to parse the PATH environment variable in the underlying platform.
- *
- * \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 = ""){
- #if defined(BOOST_POSIX_API)
- BOOST_ASSERT(file.find('/') == std::string::npos);
- #elif defined(BOOST_WINDOWS_API)
- BOOST_ASSERT(file.find_first_of("\\/") == std::string::npos);
- #endif
-
- std::string result;
-
- #if defined(BOOST_POSIX_API)
-
- if (path.empty()){
- 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());
-
- #if defined(__CYGWIN__)
- if (!::cygwin_posix_path_list_p(path.c_str())){
- int size = ::cygwin_win32_to_posix_path_list_buf_size(path.c_str());
- boost::scoped_array<char> cygpath(new char[size]);
- ::cygwin_win32_to_posix_path_list(path.c_str(), cygpath.get());
- path = cygpath.get();
- }
- #endif
-
- std::string::size_type pos1 = 0, pos2;
- 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 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());
-
- #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;
- break;
- }
- ++ext;
- }
-
- #endif
- if (result.empty()){
- boost::throw_exception(
- boost::filesystem::filesystem_error(
- "boost::process::find_executable_in_path: file not found", file,
- boost::system::errc::make_error_code(
- boost::system::errc::no_such_file_or_directory)));
+#include <boost/filesystem/path.hpp>
+#include <boost/algorithm/string/predicate.hpp>
+#include <boost/system/system_error.hpp>
+#include <boost/throw_exception.hpp>
+#include <boost/scoped_array.hpp>
+#include <boost/assert.hpp>
+#include <string>
+#include <vector>
+#include <stdexcept>
+#include <cstddef>
+
+
+namespace boost
+{
+namespace process
+{
+
+/**
+ * Locates the executable program \a file in all the directory components
+ * specified in \a path. If \a path is empty, the value of the PATH
+ * environment variable is used.
+ *
+ * The path variable is interpreted following the same conventions used
+ * to parse the PATH environment variable in the underlying platform.
+ *
+ * \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 = "")
+{
+#if defined(BOOST_POSIX_API)
+ BOOST_ASSERT(file.find('/') == std::string::npos);
+#elif defined(BOOST_WINDOWS_API)
+ BOOST_ASSERT(file.find_first_of("\\/") == std::string::npos);
+#endif
+
+ std::string result;
+
+#if defined(BOOST_POSIX_API)
+
+ if (path.empty())
+ {
+ 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;
 
- return result;
-}
+ }
+ BOOST_ASSERT(!path.empty());
 
-/**
- * Extracts the program name from a given executable.
- *
- * \return The program name. On Windows the program name
- * is returned without a file extension.
- */
-inline std::string executable_to_progname(const std::string &exe)
-{
- std::string::size_type begin = 0;
- std::string::size_type end = std::string::npos;
-
- #if defined(BOOST_POSIX_API)
- std::string::size_type slash = exe.rfind('/');
- #elif defined(BOOST_WINDOWS_API)
- std::string::size_type slash = exe.find_last_of("/\\");
- #endif
-
- if (slash != std::string::npos)
- begin = slash + 1;
-
- #if defined(BOOST_WINDOWS_API)
- if (exe.size() > 4 &&
- (boost::algorithm::iends_with(exe, ".exe")
- || boost::algorithm::iends_with(exe, ".com")
- || boost::algorithm::iends_with(exe, ".bat")
- )
- )
- end = exe.size() - 4;
- #endif
-
- return exe.substr(begin, end - begin);
-}
-
-/**
- * Starts a new child process.
- *
- * Launches a new process based on the binary image specified by the
- * executable, the set of arguments to be passed to it and several
- * parameters that describe the execution context.
- *
- * \remark Blocking remarks: This function may block if the device
- * holding the executable blocks when loading the image. This might
- * happen if, e.g., the binary is being loaded from a network share.
- *
- * \return A handle to the new child process.
- */
+#if defined(__CYGWIN__)
+ if (!::cygwin_posix_path_list_p(path.c_str()))
+ {
+ int size = ::cygwin_win32_to_posix_path_list_buf_size(path.c_str());
+ boost::scoped_array<char> cygpath(new char[size]);
+ ::cygwin_win32_to_posix_path_list(path.c_str(), cygpath.get());
+ path = cygpath.get();
+ }
+#endif
+
+ std::string::size_type pos1 = 0, pos2;
+ 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 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());
+
+#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;
+ break;
+ }
+ ++ext;
+ }
+
+#endif
+ if (result.empty())
+ {
+ boost::throw_exception(
+ boost::filesystem::filesystem_error(
+ "boost::process::find_executable_in_path: file not found", file,
+ boost::system::errc::make_error_code(
+ boost::system::errc::no_such_file_or_directory)));
+ }
+
+ return result;
+}
+
+/**
+ * Extracts the program name from a given executable.
+ *
+ * \return The program name. On Windows the program name
+ * is returned without a file extension.
+ */
+inline std::string executable_to_progname(const std::string &exe)
+{
+ std::string::size_type begin = 0;
+ std::string::size_type end = std::string::npos;
+
+#if defined(BOOST_POSIX_API)
+ std::string::size_type slash = exe.rfind('/');
+#elif defined(BOOST_WINDOWS_API)
+ std::string::size_type slash = exe.find_last_of("/\\");
+#endif
+
+ if (slash != std::string::npos)
+ begin = slash + 1;
+
+#if defined(BOOST_WINDOWS_API)
+ if (exe.size() > 4 &&
+ (boost::algorithm::iends_with(exe, ".exe")
+ || boost::algorithm::iends_with(exe, ".com")
+ || boost::algorithm::iends_with(exe, ".bat")
+ )
+ )
+ end = exe.size() - 4;
+#endif
+
+ return exe.substr(begin, end - begin);
+}
+
+/**
+ * Starts a new child process.
+ *
+ * Launches a new process based on the binary image specified by the
+ * executable, the set of arguments to be passed to it and several
+ * parameters that describe the execution context.
+ *
+ * \remark Blocking remarks: This function may block if the device
+ * holding the executable blocks when loading the image. This might
+ * happen if, e.g., the binary is being loaded from a network share.
+ *
+ * \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){
+inline child create_child(const std::string &executable, Arguments args,
+ context &ctx = DEFAULT_CONTEXT)
+{
+
+ detail::file_handle fhstdin, fhstdout, fhstderr;
 
- detail::file_handle fhstdin, fhstdout, fhstderr;
+ //start structures that represents a std stream.
+ detail::stream_detail stdin_stream(detail::stdin_type),
+ stdout_stream(detail::stdout_type),
+ stderr_stream(detail::stderr_type);
 
- //start structures that represents a std stream.
- detail::stream_detail stdin_stream(detail::stdin_type),
- stdout_stream(detail::stdout_type),
- stderr_stream(detail::stderr_type);
+ stdin_stream.behavior = ctx.stdin_behavior;
+ stdout_stream.behavior = ctx.stdout_behavior;
+ stderr_stream.behavior = ctx.stderr_behavior;
 
- stdin_stream.behavior = ctx.stdin_behavior;
- stdout_stream.behavior = ctx.stdout_behavior;
- 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);
 
- //adjust process name
- std::string p_name = ctx.process_name.empty() ? executable : ctx.process_name;
- args.insert(args.begin(),p_name);
-
 
- #if defined(BOOST_POSIX_API)
+#if defined(BOOST_POSIX_API)
 
- child::id_type pid = ::fork();
+ 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"));
- }
+ 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"));
+ }
 
- if (pid == 0){
+ if (pid == 0)
+ {
 
- //configure child pipes
- detail::configure_posix_stream(stdin_stream);
- detail::configure_posix_stream(stdout_stream);
- detail::configure_posix_stream(stderr_stream);
+ //configure child pipes
+ 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);
 
- //execve call
- std::pair<std::size_t, char**> argcv = detail::collection_to_posix_argv(args);
- char **envp = detail::environment_to_envp(ctx.environment);
+ BOOST_ASSERT(false);
 
- ::execve(executable.c_str(), argcv.second, envp);
+ }
 
- BOOST_ASSERT(false);
+ BOOST_ASSERT(pid > 0);
 
- }
+ //adjust father pipes
+ if(ctx.stdin_behavior == capture)
+ {
+ stdin_stream.object.pipe_.rend().close();
+ fhstdin = stdin_stream.object.pipe_.wend().release();
+ BOOST_ASSERT(fhstdin.valid());
+ }
 
- BOOST_ASSERT(pid > 0);
+ if(ctx.stdout_behavior == capture)
+ {
+ stdout_stream.object.pipe_.wend().close();
+ fhstdout = stdout_stream.object.pipe_.wend().release();
+ BOOST_ASSERT(fhstdout.valid());
+ }
 
+ if(ctx.stderr_behavior == capture)
+ {
+ stderr_stream.object.pipe_.wend().close();
+ fhstderr = stderr_stream.object.pipe_.wend().release();
+ BOOST_ASSERT(fhstderr.valid());
+ }
 
- //adjust father pipes
- if(ctx.stdin_behavior == capture){
- stdin_stream.object.pipe_.rend().close();
- fhstdin = stdin_stream.object.pipe_.wend().release();
- BOOST_ASSERT(fhstdin.valid());
- }
 
- if(ctx.stdout_behavior == capture){
- stdout_stream.object.pipe_.wend().close();
- fhstdout = stdout_stream.object.pipe_.wend().release();
- BOOST_ASSERT(fhstdout.valid());
- }
 
- if(ctx.stderr_behavior == capture){
- stderr_stream.object.pipe_.wend().close();
- fhstderr = stderr_stream.object.pipe_.wend().release();
- BOOST_ASSERT(fhstderr.valid());
- }
+ return child(pid, fhstdin, fhstdout, fhstderr);
 
 
+#elif defined(BOOST_WINDOWS_API)
 
- return child(pid, fhstdin, fhstdout, fhstderr);
 
+ //Set up the pipes when needed for the current process.
+ if (stdin_stream.behavior == capture)
+ fhstdin = stdin_stream.object.pipe_.wend();
+ if (stdout_stream.behavior == capture)
+ fhstdout = stdout_stream.object.pipe_.rend();
+ if (stderr_stream.behavior == capture)
+ fhstderr = stderr_stream.object.pipe_.rend();
 
- #elif defined(BOOST_WINDOWS_API)
-
 
- //Set up the pipes when needed for the current process.
- if (stdin_stream.behavior == capture)
- fhstdin = stdin_stream.object.pipe_.wend();
- if (stdout_stream.behavior == capture)
- fhstdout = stdout_stream.object.pipe_.rend();
- if (stderr_stream.behavior == capture)
- fhstderr = stderr_stream.object.pipe_.rend();
+ //define startup info from the new child
+ STARTUPINFOA startup_info;
+ ::ZeroMemory(&startup_info, sizeof(startup_info));
+ startup_info.cb = sizeof(startup_info);
 
+ startup_info.dwFlags |= STARTF_USESTDHANDLES;
 
- //define startup info from the new child
- STARTUPINFOA startup_info;
- ::ZeroMemory(&startup_info, sizeof(startup_info));
- startup_info.cb = sizeof(startup_info);
+ //configure std stream info for the child
+ //TODO: Find a better way to do it,without file handle
+ detail::file_handle fh;
 
- startup_info.dwFlags |= STARTF_USESTDHANDLES;
-
- //configure std stream info for the child
- //TODO: Find a better way to do it,without file handle
- detail::file_handle fh;
+ fh = configure_win32_stream(stdin_stream);
+ if(fh.valid())
+ startup_info.hStdInput = fh.get();
 
- fh = configure_win32_stream(stdin_stream);
- if(fh.valid())
- startup_info.hStdInput = fh.get();
-
- fh = configure_win32_stream(stdout_stream);
- if(fh.valid())
- startup_info.hStdOutput = fh.get();
+ fh = configure_win32_stream(stdout_stream);
+ if(fh.valid())
+ startup_info.hStdOutput = fh.get();
 
- fh = configure_win32_stream(stderr_stream);
- if(fh.valid())
- startup_info.hStdError = fh.get();
-
+ fh = configure_win32_stream(stderr_stream);
+ if(fh.valid())
+ startup_info.hStdError = fh.get();
 
- //define process info and create it
- PROCESS_INFORMATION pi;
- ::ZeroMemory(&pi, sizeof(pi));
 
- boost::shared_array<char> cmdline = detail::collection_to_win32_cmdline(args);
+ //define process info and create it
+ PROCESS_INFORMATION pi;
+ ::ZeroMemory(&pi, sizeof(pi));
 
- boost::scoped_array<char> exe(new char[executable.size() + 1]);
- ::strcpy_s(exe.get(), executable.size() + 1, executable.c_str());
+ boost::shared_array<char> cmdline=detail::collection_to_win32_cmdline(args);
 
- boost::scoped_array<char> workdir(new char[ctx.work_dir.size() + 1]);
- ::strcpy_s(workdir.get(), ctx.work_dir.size() + 1, ctx.work_dir.c_str());
+ boost::scoped_array<char> exe(new char[executable.size() + 1]);
+ ::strcpy_s(exe.get(), executable.size() + 1, executable.c_str());
 
- boost::shared_array<char> envstrs = detail::environment_to_win32_strings(ctx.environment);
+ boost::scoped_array<char> workdir(new char[ctx.work_dir.size() + 1]);
+ ::strcpy_s(workdir.get(), ctx.work_dir.size() + 1, ctx.work_dir.c_str());
 
- //I dare you to understand this code at first look.
- if ( ::CreateProcessA(exe.get(), cmdline.get(),
- NULL, NULL, TRUE, 0, envstrs.get(), workdir.get(),
- &startup_info, &pi) == 0)
+ boost::shared_array<char> envstrs =
+ detail::environment_to_win32_strings(ctx.environment);
 
- boost::throw_exception(boost::system::system_error(
- boost::system::error_code(
- ::GetLastError(), boost::system::get_system_category()),
- "boost::process::detail::win32_start: CreateProcess failed"));
+ //create the process
+ if ( ::CreateProcessA(exe.get(), cmdline.get(),
+ NULL, NULL, TRUE, 0, envstrs.get(), workdir.get(),
+ &startup_info, &pi) == 0)
 
+ boost::throw_exception(boost::system::system_error(
+ boost::system::error_code(::GetLastError(),
+ boost::system::get_system_category()),
+ "boost::process::detail::win32_start:\
+ CreateProcess failed"));
 
- //is this necessary?
- 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));
+ 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"));
 
- #endif
-}
+ 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){
- std::vector<std::string> args ;
- return create_child(executable,args,ctx);
+inline child create_child(const std::string &executable,
+ context &ctx = DEFAULT_CONTEXT)
+{
+ std::vector<std::string> args ;
+ return create_child(executable,args,ctx);
 }
 }
 }
 
-#endif
+#endif

Modified: sandbox/SOC/2010/process/boost/process/pistream.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/pistream.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/pistream.hpp 2010-05-27 23:09:55 EDT (Thu, 27 May 2010)
@@ -1,116 +1,118 @@
-//
-// 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)
-//
-
-/**
- * \file boost/process/pistream.hpp
- *
- * Includes the declaration of the pistream class.
- */
-
-#ifndef BOOST_PROCESS_PISTREAM_HPP
-#define BOOST_PROCESS_PISTREAM_HPP
-
-#include <boost/process/detail/file_handle.hpp>
-#include <boost/process/detail/systembuf.hpp>
-#include <boost/noncopyable.hpp>
-#include <istream>
-
-namespace boost {
-namespace process {
-
-/**
- * Child process' output stream.
- *
- * The pistream class represents an output communication channel with the
- * child process. The child process writes data to this stream and the
- * parent process can read it through the pistream object. In other
- * words, from the child's point of view, the communication channel is an
- * output one, but from the parent's point of view it is an input one;
- * hence the confusing pistream name.
- *
- * pistream objects cannot be copied because they own the file handle
- * they use to communicate with the child and because they buffer data
- * that flows through the communication channel.
- *
- * A pistream object behaves as a std::istream stream in all senses.
- * The class is only provided because it must provide a method to let
- * the caller explicitly close the communication channel.
- *
- * \remark Blocking remarks: Functions that read data from this
- * stream can block if the associated file handle blocks during
- * the read. As this class is used to communicate with child
- * processes through anonymous pipes, the most typical blocking
- * condition happens when the child has no more data to send to
- * the pipe's system buffer. When this happens, the buffer
- * eventually empties and the system blocks until the writer
- * generates some data.
- */
-class pistream : public std::istream, public boost::noncopyable
-{
-public:
- /**
- * Creates a new process' output stream.
- *
- * Given a file handle, this constructor creates a new pistream
- * object that owns the given file handle \a fh. Ownership of
- * \a fh is transferred to the created pistream object.
- *
- * \pre \a fh is valid.
- * \post \a fh is invalid.
- * \post The new pistream object owns \a fh.
- */
- explicit pistream(detail::file_handle &fh)
- : std::istream(0),
- handle_(fh),
- systembuf_(handle_.get())
- {
- rdbuf(&systembuf_);
- }
-
- /**
- * Returns the file handle managed by this stream.
- *
- * The file handle must not be copied. Copying invalidates
- * the source file handle making the pistream unusable.
- */
- detail::file_handle &handle()
- {
- return handle_;
- }
-
- /**
- * Closes the file handle managed by this stream.
- *
- * Explicitly closes the file handle managed by this stream. This
- * function can be used by the user to tell the child process it's
- * not willing to receive more data.
- */
- void close()
- {
- handle_.close();
- }
-
-private:
- /**
- * The file handle managed by this stream.
- */
- detail::file_handle handle_;
-
- /**
- * The systembuf object used to manage this stream's data.
- */
- detail::systembuf systembuf_;
-};
+//
+// 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)
+//
+
+/**
+ * \file boost/process/pistream.hpp
+ *
+ * Includes the declaration of the pistream class.
+ */
+
+#ifndef BOOST_PROCESS_PISTREAM_HPP
+#define BOOST_PROCESS_PISTREAM_HPP
+
+#include <boost/process/detail/file_handle.hpp>
+#include <boost/process/detail/systembuf.hpp>
+#include <boost/noncopyable.hpp>
+#include <istream>
+
+namespace boost
+{
+namespace process
+{
+
+/**
+ * Child process' output stream.
+ *
+ * The pistream class represents an output communication channel with the
+ * child process. The child process writes data to this stream and the
+ * parent process can read it through the pistream object. In other
+ * words, from the child's point of view, the communication channel is an
+ * output one, but from the parent's point of view it is an input one;
+ * hence the confusing pistream name.
+ *
+ * pistream objects cannot be copied because they own the file handle
+ * they use to communicate with the child and because they buffer data
+ * that flows through the communication channel.
+ *
+ * A pistream object behaves as a std::istream stream in all senses.
+ * The class is only provided because it must provide a method to let
+ * the caller explicitly close the communication channel.
+ *
+ * \remark Blocking remarks: Functions that read data from this
+ * stream can block if the associated file handle blocks during
+ * the read. As this class is used to communicate with child
+ * processes through anonymous pipes, the most typical blocking
+ * condition happens when the child has no more data to send to
+ * the pipe's system buffer. When this happens, the buffer
+ * eventually empties and the system blocks until the writer
+ * generates some data.
+ */
+class pistream : public std::istream, public boost::noncopyable
+{
+public:
+ /**
+ * Creates a new process' output stream.
+ *
+ * Given a file handle, this constructor creates a new pistream
+ * object that owns the given file handle \a fh. Ownership of
+ * \a fh is transferred to the created pistream object.
+ *
+ * \pre \a fh is valid.
+ * \post \a fh is invalid.
+ * \post The new pistream object owns \a fh.
+ */
+ explicit pistream(detail::file_handle &fh)
+ : std::istream(0),
+ handle_(fh),
+ systembuf_(handle_.get())
+ {
+ rdbuf(&systembuf_);
+ }
+
+ /**
+ * Returns the file handle managed by this stream.
+ *
+ * The file handle must not be copied. Copying invalidates
+ * the source file handle making the pistream unusable.
+ */
+ detail::file_handle &handle()
+ {
+ return handle_;
+ }
+
+ /**
+ * Closes the file handle managed by this stream.
+ *
+ * Explicitly closes the file handle managed by this stream. This
+ * function can be used by the user to tell the child process it's
+ * not willing to receive more data.
+ */
+ void close()
+ {
+ handle_.close();
+ }
+
+private:
+ /**
+ * The file handle managed by this stream.
+ */
+ detail::file_handle handle_;
+
+ /**
+ * The systembuf object used to manage this stream's data.
+ */
+ detail::systembuf systembuf_;
+};
 
-}
-}
+}
+}
 
-#endif
+#endif

Modified: sandbox/SOC/2010/process/boost/process/posix_child.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/posix_child.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/posix_child.hpp 2010-05-27 23:09:55 EDT (Thu, 27 May 2010)
@@ -1,178 +1,182 @@
-//
-// 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)
-//
-
-/**
- * \file boost/process/posix_child.hpp
- *
- * Includes the declaration of the posix_child class.
- */
-
-#ifndef BOOST_PROCESS_POSIX_CHILD_HPP
-#define BOOST_PROCESS_POSIX_CHILD_HPP
-
-#include <boost/process/child.hpp>
-#include <boost/process/pistream.hpp>
-#include <boost/process/postream.hpp>
-#include <boost/process/detail/pipe.hpp>
-#include <boost/process/detail/posix_ops.hpp>
-#include <boost/process/detail/stream_info.hpp>
-#include <boost/shared_ptr.hpp>
-#include <boost/assert.hpp>
-#include <map>
-#include <unistd.h>
-
-namespace boost {
-namespace process {
-
-/**
- * POSIX implementation of the Child concept.
- *
- * The posix_child class implements the Child concept in a POSIX
- * operating system.
- *
- * A POSIX child differs from a regular child (represented by a
- * child object) in that it supports more than three communication
- * channels with its parent. These channels are identified by regular
- * file descriptors (integers).
- *
- * This class is built on top of the generic child so as to allow its
- * trivial adoption. When a program is changed to use the POSIX-specific
- * context (posix_context), it will most certainly need to migrate its
- * use of the child class to posix_child. Doing so is only a matter of
- * redefining the appropriate object and later using the required extra
- * features: there should be no need to modify the existing code (e.g.
- * method calls) in any other way.
- */
-class posix_child : public child
-{
-public:
- /**
- * Gets a reference to the child's input stream \a desc.
- *
- * Returns a reference to a postream object that represents one of
- * the multiple input communication channels with the child process.
- * The channel is identified by \a desc as seen from the child's
- * point of view. The parent can use the returned stream to send
- * data to the child.
- *
- * Giving this function the STDIN_FILENO constant (defined in
- * unistd.h) is a synonym for the get_stdin() call inherited from
- * child.
- */
- postream &get_input(int desc) const
- {
- if (desc == STDIN_FILENO)
- return posix_child::get_stdin();
- else
- {
- input_map_t::const_iterator it = input_map_.find(desc);
- BOOST_ASSERT(it != input_map_.end());
- return *it->second;
- }
- }
-
- /**
- * Gets a reference to the child's output stream \a desc.
- *
- * Returns a reference to a pistream object that represents one of
- * the multiple output communication channels with the child process.
- * The channel is identified by \a desc as seen from the child's
- * point of view. The parent can use the returned stream to retrieve
- * data from the child.
- *
- * Giving this function the STDOUT_FILENO or STDERR_FILENO constants
- * (both defined in unistd.h) are synonyms for the get_stdout() and
- * get_stderr() calls inherited from child, respectively.
- */
- pistream &get_output(int desc) const
- {
- if (desc == STDOUT_FILENO)
- return posix_child::get_stdout();
- else if (desc == STDERR_FILENO)
- return posix_child::get_stderr();
- else
- {
- output_map_t::const_iterator it = output_map_.find(desc);
- BOOST_ASSERT(it != output_map_.end());
- return *it->second;
- }
- }
-
- /**
- * Constructs a new POSIX child object representing a just
- * spawned child process.
- *
- * Creates a new child object that represents the just spawned process
- * \a id.
- *
- * The \a infoin and \a infoout maps contain the pipes used to handle
- * the redirections of the child process; at the moment, no other
- * stream_info types are supported. If the launcher was asked to
- * redirect any of the three standard flows, their pipes must be
- * present in these maps.
- */
- posix_child(id_type id, detail::info_map &infoin, detail::info_map &infoout)
- : child(id,
- detail::posix_info_locate_pipe(infoin, STDIN_FILENO, false),
- detail::posix_info_locate_pipe(infoout, STDOUT_FILENO, true),
- detail::posix_info_locate_pipe(infoout, STDERR_FILENO, true))
- {
- for (detail::info_map::iterator it = infoin.begin(); it != infoin.end(); ++it)
- {
- detail::stream_info &si = it->second;
- if (si.type_ == detail::stream_info::use_pipe)
- {
- BOOST_ASSERT(si.pipe_->wend().valid());
- boost::shared_ptr<postream> st(new postream(si.pipe_->wend()));
- input_map_.insert(input_map_t::value_type(it->first, st));
- }
- }
-
- for (detail::info_map::iterator it = infoout.begin(); it != infoout.end(); ++it)
- {
- detail::stream_info &si = it->second;
- if (si.type_ == detail::stream_info::use_pipe)
- {
- BOOST_ASSERT(si.pipe_->rend().valid());
- boost::shared_ptr<pistream> st(new pistream(si.pipe_->rend()));
- output_map_.insert(output_map_t::value_type(it->first, st));
- }
- }
- }
-
-private:
- /**
- * Maps child's file descriptors to postream objects.
- */
- typedef std::map<int, boost::shared_ptr<postream> > input_map_t;
-
- /**
- * Contains all relationships between child's input file
- * descriptors and their corresponding postream objects.
- */
- input_map_t input_map_;
-
- /**
- * Maps child's file descriptors to pistream objects.
- */
- typedef std::map<int, boost::shared_ptr<pistream> > output_map_t;
-
- /**
- * Contains all relationships between child's output file
- * descriptors and their corresponding pistream objects.
- */
- output_map_t output_map_;
-};
+//
+// 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)
+//
+
+/**
+ * \file boost/process/posix_child.hpp
+ *
+ * Includes the declaration of the posix_child class.
+ */
+
+#ifndef BOOST_PROCESS_POSIX_CHILD_HPP
+#define BOOST_PROCESS_POSIX_CHILD_HPP
+
+#include <boost/process/child.hpp>
+#include <boost/process/pistream.hpp>
+#include <boost/process/postream.hpp>
+#include <boost/process/detail/pipe.hpp>
+#include <boost/process/detail/posix_ops.hpp>
+#include <boost/process/detail/stream_info.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/assert.hpp>
+#include <map>
+#include <unistd.h>
+
+namespace boost
+{
+namespace process
+{
+
+/**
+ * POSIX implementation of the Child concept.
+ *
+ * The posix_child class implements the Child concept in a POSIX
+ * operating system.
+ *
+ * A POSIX child differs from a regular child (represented by a
+ * child object) in that it supports more than three communication
+ * channels with its parent. These channels are identified by regular
+ * file descriptors (integers).
+ *
+ * This class is built on top of the generic child so as to allow its
+ * trivial adoption. When a program is changed to use the POSIX-specific
+ * context (posix_context), it will most certainly need to migrate its
+ * use of the child class to posix_child. Doing so is only a matter of
+ * redefining the appropriate object and later using the required extra
+ * features: there should be no need to modify the existing code (e.g.
+ * method calls) in any other way.
+ */
+class posix_child : public child
+{
+public:
+ /**
+ * Gets a reference to the child's input stream \a desc.
+ *
+ * Returns a reference to a postream object that represents one of
+ * the multiple input communication channels with the child process.
+ * The channel is identified by \a desc as seen from the child's
+ * point of view. The parent can use the returned stream to send
+ * data to the child.
+ *
+ * Giving this function the STDIN_FILENO constant (defined in
+ * unistd.h) is a synonym for the get_stdin() call inherited from
+ * child.
+ */
+ postream &get_input(int desc) const
+ {
+ if (desc == STDIN_FILENO)
+ return posix_child::get_stdin();
+ else
+ {
+ input_map_t::const_iterator it = input_map_.find(desc);
+ BOOST_ASSERT(it != input_map_.end());
+ return *it->second;
+ }
+ }
+
+ /**
+ * Gets a reference to the child's output stream \a desc.
+ *
+ * Returns a reference to a pistream object that represents one of
+ * the multiple output communication channels with the child process.
+ * The channel is identified by \a desc as seen from the child's
+ * point of view. The parent can use the returned stream to retrieve
+ * data from the child.
+ *
+ * Giving this function the STDOUT_FILENO or STDERR_FILENO constants
+ * (both defined in unistd.h) are synonyms for the get_stdout() and
+ * get_stderr() calls inherited from child, respectively.
+ */
+ pistream &get_output(int desc) const
+ {
+ if (desc == STDOUT_FILENO)
+ return posix_child::get_stdout();
+ else if (desc == STDERR_FILENO)
+ return posix_child::get_stderr();
+ else
+ {
+ output_map_t::const_iterator it = output_map_.find(desc);
+ BOOST_ASSERT(it != output_map_.end());
+ return *it->second;
+ }
+ }
+
+ /**
+ * Constructs a new POSIX child object representing a just
+ * spawned child process.
+ *
+ * Creates a new child object that represents the just spawned process
+ * \a id.
+ *
+ * The \a infoin and \a infoout maps contain the pipes used to handle
+ * the redirections of the child process; at the moment, no other
+ * stream_info types are supported. If the launcher was asked to
+ * redirect any of the three standard flows, their pipes must be
+ * present in these maps.
+ */
+ posix_child(id_type id, detail::info_map &infoin, detail::info_map &infoout)
+ : child(id,
+ detail::posix_info_locate_pipe(infoin, STDIN_FILENO, false),
+ detail::posix_info_locate_pipe(infoout, STDOUT_FILENO, true),
+ detail::posix_info_locate_pipe(infoout, STDERR_FILENO, true))
+ {
+ for (detail::info_map::iterator it = infoin.begin();
+ it != infoin.end(); ++it)
+ {
+ detail::stream_info &si = it->second;
+ if (si.type_ == detail::stream_info::use_pipe)
+ {
+ BOOST_ASSERT(si.pipe_->wend().valid());
+ boost::shared_ptr<postream> st(new postream(si.pipe_->wend()));
+ input_map_.insert(input_map_t::value_type(it->first, st));
+ }
+ }
+
+ for (detail::info_map::iterator it = infoout.begin();
+ it != infoout.end(); ++it)
+ {
+ detail::stream_info &si = it->second;
+ if (si.type_ == detail::stream_info::use_pipe)
+ {
+ BOOST_ASSERT(si.pipe_->rend().valid());
+ boost::shared_ptr<pistream> st(new pistream(si.pipe_->rend()));
+ output_map_.insert(output_map_t::value_type(it->first, st));
+ }
+ }
+ }
+
+private:
+ /**
+ * Maps child's file descriptors to postream objects.
+ */
+ typedef std::map<int, boost::shared_ptr<postream> > input_map_t;
+
+ /**
+ * Contains all relationships between child's input file
+ * descriptors and their corresponding postream objects.
+ */
+ input_map_t input_map_;
+
+ /**
+ * Maps child's file descriptors to pistream objects.
+ */
+ typedef std::map<int, boost::shared_ptr<pistream> > output_map_t;
+
+ /**
+ * Contains all relationships between child's output file
+ * descriptors and their corresponding pistream objects.
+ */
+ output_map_t output_map_;
+};
 
-}
-}
+}
+}
 
-#endif
+#endif

Modified: sandbox/SOC/2010/process/boost/process/postream.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/postream.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/postream.hpp 2010-05-27 23:09:55 EDT (Thu, 27 May 2010)
@@ -1,113 +1,119 @@
-//
-// 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)
-//
-
-/**
- * \file boost/process/postream.hpp
- *
- * Includes the declaration of the postream class.
- */
-
-#ifndef BOOST_PROCESS_POSTREAM_HPP
-#define BOOST_PROCESS_POSTREAM_HPP
-
-#include <boost/process/detail/file_handle.hpp>
-#include <boost/process/detail/systembuf.hpp>
-#include <boost/noncopyable.hpp>
-#include <ostream>
-
-namespace boost {
-namespace process {
-
-/**
- * Child process' input stream.
- *
- * The postream class represents an input communication channel with the
- * child process. The child process reads data from this stream and the
- * parent process can write to it through the postream object. In other
- * words, from the child's point of view, the communication channel is an
- * input one, but from the parent's point of view it is an output one;
- * hence the confusing postream name.
- *
- * postream objects cannot be copied because they own the file handle
- * they use to communicate with the child and because they buffer data
- * that flows through the communication channel.
- *
- * A postream object behaves as a std::ostream stream in all senses.
- * The class is only provided because it must provide a method to let
- * the caller explicitly close the communication channel.
- *
- * \remark Blocking remarks: Functions that write data to this
- * stream can block if the associated file handle blocks during
- * the write. As this class is used to communicate with child
- * processes through anonymous pipes, the most typical blocking
- * condition happens when the child is not processing the data
- * in the pipe's system buffer. When this happens, the buffer
- * eventually fills up and the system blocks until the reader
- * consumes some data, leaving some new room.
- */
-class postream : public std::ostream, public boost::noncopyable{
+//
+// 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)
+//
+
+/**
+ * \file boost/process/postream.hpp
+ *
+ * Includes the declaration of the postream class.
+ */
+
+#ifndef BOOST_PROCESS_POSTREAM_HPP
+#define BOOST_PROCESS_POSTREAM_HPP
+
+#include <boost/process/detail/file_handle.hpp>
+#include <boost/process/detail/systembuf.hpp>
+#include <boost/noncopyable.hpp>
+#include <ostream>
+
+namespace boost
+{
+namespace process
+{
+
+/**
+ * Child process' input stream.
+ *
+ * The postream class represents an input communication channel with the
+ * child process. The child process reads data from this stream and the
+ * parent process can write to it through the postream object. In other
+ * words, from the child's point of view, the communication channel is an
+ * input one, but from the parent's point of view it is an output one;
+ * hence the confusing postream name.
+ *
+ * postream objects cannot be copied because they own the file handle
+ * they use to communicate with the child and because they buffer data
+ * that flows through the communication channel.
+ *
+ * A postream object behaves as a std::ostream stream in all senses.
+ * The class is only provided because it must provide a method to let
+ * the caller explicitly close the communication channel.
+ *
+ * \remark Blocking remarks: Functions that write data to this
+ * stream can block if the associated file handle blocks during
+ * the write. As this class is used to communicate with child
+ * processes through anonymous pipes, the most typical blocking
+ * condition happens when the child is not processing the data
+ * in the pipe's system buffer. When this happens, the buffer
+ * eventually fills up and the system blocks until the reader
+ * consumes some data, leaving some new room.
+ */
+class postream : public std::ostream, public boost::noncopyable
+{
 public:
- /**
- * Creates a new process' input stream.
- *
- * Given a file handle, this constructor creates a new postream
- * object that owns the given file handle \a fh. Ownership of
- * \a fh is transferred to the created postream object.
- *
- * \pre \a fh is valid.
- * \post \a fh is invalid.
- * \post The new postream object owns \a fh.
- */
- explicit postream(detail::file_handle &fh)
- : std::ostream(0),
- handle_(fh),
- systembuf_(handle_.get()){
- rdbuf(&systembuf_);
- }
-
- /**
- * Returns the file handle managed by this stream.
- *
- * The file handle must not be copied. Copying invalidates
- * the source file handle making the postream unusable.
- */
- detail::file_handle &handle(){
- return handle_;
- }
-
- /**
- * Closes the file handle managed by this stream.
- *
- * Explicitly closes the file handle managed by this stream. This
- * function can be used by the user to tell the child process there
- * is no more data to send.
- */
- void close(){
- systembuf_.sync();
- handle_.close();
- }
-
-private:
- /**
- * The file handle managed by this stream.
- */
- detail::file_handle handle_;
-
- /**
- * The systembuf object used to manage this stream's data.
- */
- detail::systembuf systembuf_;
-};
+ /**
+ * Creates a new process' input stream.
+ *
+ * Given a file handle, this constructor creates a new postream
+ * object that owns the given file handle \a fh. Ownership of
+ * \a fh is transferred to the created postream object.
+ *
+ * \pre \a fh is valid.
+ * \post \a fh is invalid.
+ * \post The new postream object owns \a fh.
+ */
+ explicit postream(detail::file_handle &fh)
+ : std::ostream(0),
+ handle_(fh),
+ systembuf_(handle_.get())
+ {
+ rdbuf(&systembuf_);
+ }
+
+ /**
+ * Returns the file handle managed by this stream.
+ *
+ * The file handle must not be copied. Copying invalidates
+ * the source file handle making the postream unusable.
+ */
+ detail::file_handle &handle()
+ {
+ return handle_;
+ }
+
+ /**
+ * Closes the file handle managed by this stream.
+ *
+ * Explicitly closes the file handle managed by this stream. This
+ * function can be used by the user to tell the child process there
+ * is no more data to send.
+ */
+ void close()
+ {
+ systembuf_.sync();
+ handle_.close();
+ }
+
+private:
+ /**
+ * The file handle managed by this stream.
+ */
+ detail::file_handle handle_;
+
+ /**
+ * The systembuf object used to manage this stream's data.
+ */
+ detail::systembuf systembuf_;
+};
 
-}
-}
+}
+}
 
-#endif
+#endif

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-05-27 23:09:55 EDT (Thu, 27 May 2010)
@@ -1,172 +1,203 @@
-//
-// 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)
-//
-
-/**
- * \file boost/process/process.hpp
- *
- * Includes the declaration of the process class.
- */
+//
+// 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)
+//
+
+/**
+ * \file boost/process/process.hpp
+ *
+ * Includes the declaration of the process class.
+ */
 
-#ifndef BOOST_PROCESS_PROCESS_HPP
-#define BOOST_PROCESS_PROCESS_HPP
+#ifndef BOOST_PROCESS_PROCESS_HPP
+#define BOOST_PROCESS_PROCESS_HPP
 
 
 #include <boost/process/config.hpp>
-#include <boost/process/status.hpp>
+#include <boost/process/status.hpp>
 
-#if defined(BOOST_POSIX_API)
- #include <cerrno>
- #include <signal.h>
-#elif defined(BOOST_WINDOWS_API)
- #include <cstdlib>
- #include <windows.h>
-#else
- #error "Unsupported platform."
-#endif
-
-#include <boost/system/system_error.hpp>
-#include <boost/throw_exception.hpp>
-#include <boost/shared_ptr.hpp>
-
-namespace boost {
-namespace process {
-
-/**
- * Generic implementation of the Process concept.
- *
- * The process class implements the Process concept in an operating system
- * agnostic way.
- */
-class process
-{
-public:
-#if defined(BOOST_PROCESS_DOXYGEN)
- /**
- * Opaque name for the native process' identifier type.
- *
- * Each operating system identifies processes using a specific type.
- * The \a id_type type is used to transparently refer to a process
- * regardless of the operating system in which this class is used.
- *
- * This type is guaranteed to be an integral type on all supported
- * platforms.
- */
- typedef NativeProcessId id_type;
-#elif defined(BOOST_POSIX_API)
- typedef pid_t id_type;
-#elif defined(BOOST_WINDOWS_API)
- typedef DWORD id_type;
-#endif
-
- /**
- * Constructs a new process object.
- *
- * Creates a new process object that represents a running process
- * within the system.
- */
- process(id_type id)
- : id_(id){
- }
-
- /**
- * Returns the process' identifier.
- */
- id_type get_id() const{
- return id_;
- }
-
- /**
- * Terminates the process execution.
- *
- * Forces the termination of the process execution. Some platforms
- * allow processes to ignore some external termination notifications
- * or to capture them for a proper exit cleanup. You can set the
- * \a force flag to true in them to force their termination regardless
- * of any exit handler.
- *
- * After this call, accessing this object can be dangerous because the
- * process identifier may have been reused by a different process. It
- * might still be valid, though, if the process has refused to die.
- *
- * \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)
- boost::throw_exception(boost::system::system_error(boost::system::error_code(::GetLastError(), boost::system::get_system_category()), "boost::process::process::terminate: OpenProcess failed"));
-
- if (!::TerminateProcess(h, EXIT_FAILURE)){
- ::CloseHandle(h);
- boost::throw_exception(boost::system::system_error(boost::system::error_code(::GetLastError(), boost::system::get_system_category()), "boost::process::process::terminate: TerminateProcess failed"));
- }
- if (!::CloseHandle(h))
- 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.
- *
- * Returns a status object that represents the child process'
- * finalization condition. The child process object ceases to be
- * valid after this call.
- *
- * \remark Blocking remarks: This call blocks if the child
- * process has not finalized execution and waits until
- * it terminates.
- */
- status wait(){
- #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"));
- 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){
-
- 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"));
- }
- return status(code);
- #endif
- }
-
-
- #if defined(BOOST_WINDOWS_API)
- /**
- * Process handle owned by RAII object.
- */
- boost::shared_ptr<void> process_handle_;
- #endif
-
-private:
- /**
- * The process' identifier.
- */
- id_type id_;
+#if defined(BOOST_POSIX_API)
+#include <cerrno>
+#include <signal.h>
+#elif defined(BOOST_WINDOWS_API)
+#include <cstdlib>
+#include <windows.h>
+#else
+#error "Unsupported platform."
+#endif
+
+#include <boost/system/system_error.hpp>
+#include <boost/throw_exception.hpp>
+#include <boost/shared_ptr.hpp>
+
+namespace boost
+{
+namespace process
+{
+
+/**
+ * Generic implementation of the Process concept.
+ *
+ * The process class implements the Process concept in an operating system
+ * agnostic way.
+ */
+class process
+{
+public:
+#if defined(BOOST_PROCESS_DOXYGEN)
+ /**
+ * Opaque name for the native process' identifier type.
+ *
+ * Each operating system identifies processes using a specific type.
+ * The \a id_type type is used to transparently refer to a process
+ * regardless of the operating system in which this class is used.
+ *
+ * This type is guaranteed to be an integral type on all supported
+ * platforms.
+ */
+ typedef NativeProcessId id_type;
+#elif defined(BOOST_POSIX_API)
+ typedef pid_t id_type;
+#elif defined(BOOST_WINDOWS_API)
+ typedef DWORD id_type;
+#endif
+
+ /**
+ * Constructs a new process object.
+ *
+ * Creates a new process object that represents a running process
+ * within the system.
+ */
+ process(id_type id)
+ : id_(id)
+ {
+ }
+
+ /**
+ * Returns the process' identifier.
+ */
+ id_type get_id() const
+ {
+ return id_;
+ }
+
+ /**
+ * Terminates the process execution.
+ *
+ * Forces the termination of the process execution. Some platforms
+ * allow processes to ignore some external termination notifications
+ * or to capture them for a proper exit cleanup. You can set the
+ * \a force flag to true in them to force their termination regardless
+ * of any exit handler.
+ *
+ * After this call, accessing this object can be dangerous because the
+ * process identifier may have been reused by a different process. It
+ * might still be valid, though, if the process has refused to die.
+ *
+ * \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)
+ boost::throw_exception(boost::system::system_error(
+ boost::system::error_code(::GetLastError(),
+ boost::system::get_system_category()),
+ "boost::process::process::terminate:\
+ OpenProcess failed"));
+
+ if (!::TerminateProcess(h, EXIT_FAILURE))
+ {
+ ::CloseHandle(h);
+ boost::throw_exception(boost::system::system_error(
+ boost::system::error_code(::GetLastError(),
+ boost::system::get_system_category()),
+ "boost::process::process::terminate:\
+ TerminateProcess failed"));
+ }
+ if (!::CloseHandle(h))
+ 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.
+ *
+ * Returns a status object that represents the child process'
+ * finalization condition. The child process object ceases to be
+ * valid after this call.
+ *
+ * \remark Blocking remarks: This call blocks if the child
+ * process has not finalized execution and waits until
+ * it terminates.
+ */
+ status wait()
+ {
+#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"));
+ 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)
+ {
+
+ 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"));
+ }
+ return status(code);
+#endif
+ }
+
+
+#if defined(BOOST_WINDOWS_API)
+ /**
+ * Process handle owned by RAII object.
+ */
+ boost::shared_ptr<void> process_handle_;
+#endif
+
+private:
+ /**
+ * The process' identifier.
+ */
+ id_type id_;
 
 
 };
-}
 }
-#endif
+}
+#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-05-27 23:09:55 EDT (Thu, 27 May 2010)
@@ -1,164 +1,178 @@
-//
-// 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)
-//
-
-/**
- * \file boost/process/self.hpp
- *
- * Includes the declaration of the self class.
- */
-
-#ifndef BOOST_PROCESS_SELF_HPP
-#define BOOST_PROCESS_SELF_HPP
-
-#include <boost/process/config.hpp>
-
-#if defined(BOOST_POSIX_API)
- #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
-
-#include <boost/process/process.hpp>
-#include <boost/process/environment.hpp>
-#include <boost/system/system_error.hpp>
-#include <boost/throw_exception.hpp>
-#include <boost/noncopyable.hpp>
-#include <string>
+//
+// 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)
+//
+
+/**
+ * \file boost/process/self.hpp
+ *
+ * Includes the declaration of the self class.
+ */
+
+#ifndef BOOST_PROCESS_SELF_HPP
+#define BOOST_PROCESS_SELF_HPP
+
+#include <boost/process/config.hpp>
+
+#if defined(BOOST_POSIX_API)
+#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
+
+#include <boost/process/process.hpp>
+#include <boost/process/environment.hpp>
+#include <boost/system/system_error.hpp>
+#include <boost/throw_exception.hpp>
+#include <boost/noncopyable.hpp>
+#include <string>
 #include <iostream>
 
-#if defined(BOOST_POSIX_API)
-extern "C"
-{
- extern char **environ;
-}
-#endif
-
-namespace boost {
-namespace process {
-
-/**
- * Generic implementation of the Process concept.
- *
- * The self singleton provides access to the current process.
- */
-class self : public process, boost::noncopyable{
-public:
- /**
- * Returns the self instance representing the caller's process.
- */
- static self &get_instance(){
- static self *instance = 0;
- if (!instance)
- instance = new self;
- return *instance;
- }
-
- /**
- * Returns the current environment.
- *
- * Returns the current process' environment variables. Modifying the
- * returned object has no effect on the current environment.
- */
- static environment_t get_environment(){
- environment_t e;
-
- #if defined(BOOST_POSIX_API)
- #if defined(__APPLE__)
- char **env = *_NSGetEnviron();
- #else
- char **env = ::environ;
- #endif
-
- while (*env){
- std::string s = *env;
- std::string::size_type pos = s.find('=');
- e.insert(boost::process::environment_t::value_type(
- s.substr(0, pos), s.substr(pos + 1)));
- ++env;
- }
-
- #elif defined(BOOST_WINDOWS_API)
- #ifdef GetEnvironmentStrings
- #undef GetEnvironmentStrings
- #endif
-
- char *ms_environ = ::GetEnvironmentStrings();
- if (!ms_environ)
- boost::throw_exception(boost::system::system_error(boost::system::error_code(::GetLastError(), boost::system::get_system_category()), "boost::process::self::get_environment: GetEnvironmentStrings failed"));
- try{
- char *env = ms_environ;
- while (*env){
- std::string s = env;
- std::string::size_type pos = s.find('=');
- e.insert(boost::process::environment_t::value_type(
- s.substr(0, pos), s.substr(pos + 1))
- );
- env += s.size() + 1;
- }
- }
- catch (...){
- ::FreeEnvironmentStringsA(ms_environ);
- throw;
- }
- ::FreeEnvironmentStringsA(ms_environ);
- #endif
+#if defined(BOOST_POSIX_API)
+extern "C"
+{
+ extern char **environ;
+}
+#endif
+
+namespace boost
+{
+namespace process
+{
+
+/**
+ * Generic implementation of the Process concept.
+ *
+ * The self singleton provides access to the current process.
+ */
+class self : public process, boost::noncopyable
+{
+public:
+ /**
+ * Returns the self instance representing the caller's process.
+ */
+ static self &get_instance()
+ {
+ static self *instance = 0;
+ if (!instance)
+ instance = new self;
+ return *instance;
+ }
+
+ /**
+ * Returns the current environment.
+ *
+ * Returns the current process' environment variables. Modifying the
+ * returned object has no effect on the current environment.
+ */
+ static environment_t get_environment()
+ {
+ environment_t e;
+
+#if defined(BOOST_POSIX_API)
+#if defined(__APPLE__)
+ char **env = *_NSGetEnviron();
+#else
+ char **env = ::environ;
+#endif
+
+ while (*env)
+ {
+ std::string s = *env;
+ std::string::size_type pos = s.find('=');
+ e.insert(boost::process::environment_t::value_type(
+ s.substr(0, pos), s.substr(pos + 1)));
+ ++env;
+ }
 
- return e;
+#elif defined(BOOST_WINDOWS_API)
+#ifdef GetEnvironmentStrings
+#undef GetEnvironmentStrings
+#endif
+
+ char *ms_environ = ::GetEnvironmentStrings();
+ if (!ms_environ)
+ boost::throw_exception(boost::system::system_error(
+ boost::system::error_code(::GetLastError(),
+ boost::system::get_system_category()),
+ "boost::process::self::get_environment:\
+ GetEnvironmentStrings failed"));
+ try
+ {
+ char *env = ms_environ;
+ while (*env)
+ {
+ std::string s = env;
+ std::string::size_type pos = s.find('=');
+ e.insert(boost::process::environment_t::value_type(
+ s.substr(0, pos), s.substr(pos + 1))
+ );
+ env += s.size() + 1;
+ }
+ }
+ catch (...)
+ {
+ ::FreeEnvironmentStringsA(ms_environ);
+ throw;
         }
+ ::FreeEnvironmentStringsA(ms_environ);
+#endif
 
+ return e;
+ }
 
- static char * get_work_dir(){
- #if defined(BOOST_POSIX_API)
- int size = pathconf(".",_PC_PATH_MAX);
- char * buffer = (char *)malloc(size);
- if(buffer == NULL)
- BOOST_ASSERT(false);
- return getcwd(buffer, size);
 
- #elif defined(BOOST_WINDOWS_API)
+ static char * get_work_dir()
+ {
+#if defined(BOOST_POSIX_API)
+ int size = pathconf(".",_PC_PATH_MAX);
+ char * buffer = (char *)malloc(size);
+ if(buffer == NULL)
+ BOOST_ASSERT(false);
+ return getcwd(buffer, size);
 
- char* buffer;
+#elif defined(BOOST_WINDOWS_API)
 
- BOOST_ASSERT( (buffer = _getcwd( NULL, 0 )) != NULL );
- return buffer;
+ char* buffer;
 
- #endif
+ BOOST_ASSERT( (buffer = _getcwd( NULL, 0 )) != NULL );
+ return buffer;
 
- }
+#endif
+
+ }
 
-private:
- /**
- * Constructs a new self object.
- *
- * Creates a new self object that represents the current process.
- */
- self() :
- #if defined(BOOST_POSIX_API)
- process(::getpid())
- #elif defined(BOOST_WINDOWS_API)
- process(::GetCurrentProcessId())
- #endif
- {}
+private:
+ /**
+ * Constructs a new self object.
+ *
+ * Creates a new self object that represents the current process.
+ */
+ self() :
+#if defined(BOOST_POSIX_API)
+ process(::getpid())
+#elif defined(BOOST_WINDOWS_API)
+ process(::GetCurrentProcessId())
+#endif
+ {}
 
-};
+};
 
-}
-}
+}
+}
 
-#endif
+#endif

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-05-27 23:09:55 EDT (Thu, 27 May 2010)
@@ -1,104 +1,109 @@
-//
-// 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)
-//
-
-/**
- * \file boost/process/status.hpp
- *
- * Includes the declaration of the status class.
- */
-
-#ifndef BOOST_PROCESS_STATUS_HPP
-#define BOOST_PROCESS_STATUS_HPP
-
-#include <boost/process/config.hpp>
-
-#if defined(BOOST_POSIX_API)
- #include <sys/wait.h>
-#elif defined(BOOST_WINDOWS_API)
-
-#else
- # error "Unsupported platform."
-#endif
-
-#include <boost/assert.hpp>
-
-namespace boost {
-namespace process {
-
-class process;
-
-/**
- * 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
- */
-class status{
- friend class process;
-
- public:
- /**
- * Returns whether the process exited gracefully or not.
- */
- bool exited() const{
- #if defined(BOOST_POSIX_API)
- return WIFEXITED(flags_);
- #elif defined(BOOST_WINDOWS_API)
- //TODO: Is that really right?
- return true;
- #endif
- }
-
- /**
- * If exited, returns the exit code.
- *
- * If the process exited, returns the exit code it returned.
- *
- * \pre exited() is true.
- */
-
- int exit_code() const{
- BOOST_ASSERT(exited());
-
- #if defined(BOOST_POSIX_API)
- return WEXITSTATUS(flags_);
- #elif defined(BOOST_WINDOWS_API)
- return flags_;
- #endif
- }
-
- protected:
- /**
- * Creates a status object based on exit information.
- *
- * Creates a new status object representing the exit status of a
- * child process.
- *
- * \param flags In a POSIX system this parameter contains the
- * flags returned by the ::waitpid() call. In a
- * Windows system it contains the exit code only.
- */
- status(int flags)
- : flags_(flags){}
-
- /**
- * OS-specific codification of exit status.
- */
- int flags_;
-};
+//
+// 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)
+//
+
+/**
+ * \file boost/process/status.hpp
+ *
+ * Includes the declaration of the status class.
+ */
+
+#ifndef BOOST_PROCESS_STATUS_HPP
+#define BOOST_PROCESS_STATUS_HPP
+
+#include <boost/process/config.hpp>
+
+#if defined(BOOST_POSIX_API)
+#include <sys/wait.h>
+#elif defined(BOOST_WINDOWS_API)
+
+#else
+# error "Unsupported platform."
+#endif
+
+#include <boost/assert.hpp>
+
+namespace boost
+{
+namespace process
+{
+
+class process;
+
+/**
+ * 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
+ */
+class status
+{
+ friend class process;
+
+public:
+ /**
+ * Returns whether the process exited gracefully or not.
+ */
+ bool exited() const
+ {
+#if defined(BOOST_POSIX_API)
+ return WIFEXITED(flags_);
+#elif defined(BOOST_WINDOWS_API)
+ //TODO: Is that really right?
+ return true;
+#endif
+ }
+
+ /**
+ * If exited, returns the exit code.
+ *
+ * If the process exited, returns the exit code it returned.
+ *
+ * \pre exited() is true.
+ */
+
+ int exit_code() const
+ {
+ BOOST_ASSERT(exited());
+
+#if defined(BOOST_POSIX_API)
+ return WEXITSTATUS(flags_);
+#elif defined(BOOST_WINDOWS_API)
+ return flags_;
+#endif
+ }
+
+protected:
+ /**
+ * Creates a status object based on exit information.
+ *
+ * Creates a new status object representing the exit status of a
+ * child process.
+ *
+ * \param flags In a POSIX system this parameter contains the
+ * flags returned by the ::waitpid() call. In a
+ * Windows system it contains the exit code only.
+ */
+ status(int flags)
+ : flags_(flags) {}
+
+ /**
+ * OS-specific codification of exit status.
+ */
+ int flags_;
+};
 
-}
-}
+}
+}
 
-#endif
+#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-05-27 23:09:55 EDT (Thu, 27 May 2010)
@@ -1,43 +1,45 @@
-//
-// 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)
-//
-
-/**
- * \file boost/process/stream_behavior.hpp
- *
+//
+// 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)
+//
+
+/**
+ * \file boost/process/stream_behavior.hpp
+ *
  * Includes the declaration of the stream_behavior
  *
- */
+ */
+
+#ifndef BOOST_PROCESS_STREAM_BEHAVIOR_HPP
+#define BOOST_PROCESS_STREAM_BEHAVIOR_HPP
 
-#ifndef BOOST_PROCESS_STREAM_BEHAVIOR_HPP
-#define BOOST_PROCESS_STREAM_BEHAVIOR_HPP
+#include <boost/process/config.hpp>
 
-#include <boost/process/config.hpp>
+namespace boost
+{
+namespace process
+{
 
-namespace boost {
-namespace process {
-
- /*
- *
- * stream_behavior defines how a stream should behavior
- * from a brand-new child.
- *
- * 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
- *
- */
- enum stream_behavior { inherit, capture, closed, dummy};
+/*
+ *
+ * stream_behavior defines how a stream should behavior
+ * from a brand-new child.
+ *
+ * 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
+ *
+ */
+enum stream_behavior { inherit, capture, closed, dummy};
 
 }
 }
 
-#endif
+#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