[prev in list] [next in list] [prev in thread] [next in thread]
List: boost-commit
Subject: [Boost-commit] svn:boost r64503 - in sandbox/SOC/2010/process:
From: boris () highscore ! de
Date: 2010-07-31 16:59:20
Message-ID: 20100731165920.9D61C2F8485 () wowbagger ! osl ! iu ! edu
[Download RAW message or body]
Author: bschaeling
Date: 2010-07-31 12:59:13 EDT (Sat, 31 Jul 2010)
New Revision: 64503
URL: http://svn.boost.org/trac/boost/changeset/64503
Log:
Checked in documentation and updated examples
Added:
sandbox/SOC/2010/process/libs/process/doc/
sandbox/SOC/2010/process/libs/process/doc/Jamfile.jam (contents, props changed)
sandbox/SOC/2010/process/libs/process/doc/asyncio.qbk (contents, props changed)
sandbox/SOC/2010/process/libs/process/doc/childprocess.qbk (contents, props \
changed) sandbox/SOC/2010/process/libs/process/doc/communication.qbk (contents, \
props changed) sandbox/SOC/2010/process/libs/process/doc/context.qbk (contents, \
props changed) sandbox/SOC/2010/process/libs/process/doc/posix.qbk (contents, \
props changed) sandbox/SOC/2010/process/libs/process/doc/preface.qbk (contents, \
props changed) sandbox/SOC/2010/process/libs/process/doc/process.qbk (contents, \
props changed) sandbox/SOC/2010/process/libs/process/doc/terminating.qbk \
(contents, props changed) \
sandbox/SOC/2010/process/libs/process/doc/userstreambehaviors.qbk (contents, props \
changed) sandbox/SOC/2010/process/libs/process/doc/waiting.qbk (contents, props \
changed) sandbox/SOC/2010/process/libs/process/doc/windows.qbk (contents, props \
changed) sandbox/SOC/2010/process/libs/process/example/Jamfile.jam (contents, \
props changed) sandbox/SOC/2010/process/libs/process/example/async_io.cpp \
(contents, props changed) \
sandbox/SOC/2010/process/libs/process/example/async_wait.cpp (contents, props \
changed) sandbox/SOC/2010/process/libs/process/example/chroot_setup.cpp (contents, \
props changed) sandbox/SOC/2010/process/libs/process/example/create_child.cpp \
(contents, props changed) \
sandbox/SOC/2010/process/libs/process/example/create_child_context.cpp (contents, \
props changed) sandbox/SOC/2010/process/libs/process/example/create_child_overloads.cpp \
(contents, props changed) \
sandbox/SOC/2010/process/libs/process/example/file_descriptors_setup.cpp (contents, \
props changed) sandbox/SOC/2010/process/libs/process/example/redirect_to.cpp \
(contents, props changed) sandbox/SOC/2010/process/libs/process/example/shell.cpp \
(contents, props changed) \
sandbox/SOC/2010/process/libs/process/example/startupinfo_setup.cpp (contents, \
props changed) sandbox/SOC/2010/process/libs/process/example/sync_wait.cpp \
(contents, props changed) \
sandbox/SOC/2010/process/libs/process/example/terminate.cpp (contents, props \
changed) Removed:
sandbox/SOC/2010/process/libs/process/example/create_process.cpp
sandbox/SOC/2010/process/libs/process/example/process_factory.cpp
sandbox/SOC/2010/process/libs/process/example/read_async_from_child.cpp
sandbox/SOC/2010/process/libs/process/example/read_async_from_parent.cpp
sandbox/SOC/2010/process/libs/process/example/read_from_child.cpp
sandbox/SOC/2010/process/libs/process/example/read_from_parent.cpp
sandbox/SOC/2010/process/libs/process/example/read_info_from_process.cpp
sandbox/SOC/2010/process/libs/process/example/read_sync_from_child.cpp
sandbox/SOC/2010/process/libs/process/example/terminate_child.cpp
sandbox/SOC/2010/process/libs/process/example/wait_async_child.cpp
sandbox/SOC/2010/process/libs/process/example/wait_async_process.cpp
sandbox/SOC/2010/process/libs/process/example/wait_child.cpp
sandbox/SOC/2010/process/libs/process/example/wait_process.cpp
sandbox/SOC/2010/process/libs/process/example/wait_sync_child.cpp
sandbox/SOC/2010/process/libs/process/example/write_async_to_child.cpp
sandbox/SOC/2010/process/libs/process/example/write_async_to_parent.cpp
sandbox/SOC/2010/process/libs/process/example/write_info_to_child.cpp
sandbox/SOC/2010/process/libs/process/example/write_info_to_self.cpp
sandbox/SOC/2010/process/libs/process/example/write_sync_to_child.cpp
sandbox/SOC/2010/process/libs/process/example/write_to_child.cpp
sandbox/SOC/2010/process/libs/process/example/write_to_parent.cpp
Text files modified:
sandbox/SOC/2010/process/boost/process/config.hpp | 18 ++++++---- \
sandbox/SOC/2010/process/boost/process/context.hpp | 37 \
++++++++++++++-------- \
sandbox/SOC/2010/process/boost/process/operations.hpp | 65 \
++++++++++++++++----------------------- \
sandbox/SOC/2010/process/boost/process/pipe.hpp | 11 ++++- \
sandbox/SOC/2010/process/boost/process/pistream.hpp | 2 \
sandbox/SOC/2010/process/boost/process/postream.hpp | 2 \
sandbox/SOC/2010/process/boost/process/stream_behavior.hpp | 11 +++--- \
sandbox/SOC/2010/process/libs/process/test/Jamfile.jam | 4 +- \
sandbox/SOC/2010/process/libs/process/test/arguments.cpp | 2 \
sandbox/SOC/2010/process/libs/process/test/child.cpp | 30 \
+++++++++--------- 10 files changed, 95 insertions(+), 87 \
deletions(-)
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-07-31 12:59:13 EDT (Sat, \
31 Jul 2010) @@ -14,8 +14,8 @@
/**
* \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.
+ * Defines macros that are used by the library to determine the operating
+ * system it is running under and the features it supports.
*/
#ifndef BOOST_PROCESS_CONFIG_HPP
@@ -31,24 +31,27 @@
# include <errno.h>
#elif defined(BOOST_WINDOWS_API)
# include <windows.h>
-#endif
+#endif
#if defined(BOOST_POSIX_API) || defined(BOOST_PROCESS_DOXYGEN)
-# if !defined(BOOST_PROCESS_POSIX_PATH_MAX)
+# if !defined(BOOST_PROCESS_POSIX_PATH_MAX) || defined(BOOST_PROCESS_DOXYGEN)
/**
+ * Specifies the system's maximal supported path length.
+ *
* 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 calling boost::process::self::get_work_dir().
- * This function tries to find out the maximal supported path length but uses
+ * The function tries to retrieve the maximal supported path length but uses
* BOOST_PROCESS_POSIX_PATH_MAX if it fails. Please note that the function is
- * also called when you instantiate a context.
+ * also called by the constructor of boost::process::context.
*/
# define BOOST_PROCESS_POSIX_PATH_MAX 259
# endif
#endif
+/** \cond */
#define BOOST_PROCESS_SOURCE_LOCATION \
"in file '" __FILE__ "', line " BOOST_PP_STRINGIZE(__LINE__) ": "
@@ -61,7 +64,8 @@
#define BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR(what) \
boost::throw_exception(boost::system::system_error( \
boost::system::error_code(BOOST_PROCESS_LAST_ERROR, \
- boost::system::get_system_category()), \
+ boost::system::get_system_category()), \
BOOST_PROCESS_SOURCE_LOCATION what))
+/** \endcond */
#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-07-31 12:59:13 EDT (Sat, \
31 Jul 2010) @@ -22,10 +22,11 @@
#include <boost/process/config.hpp>
#if defined(BOOST_POSIX_API)
+# include <vector>
# include <unistd.h>
#elif defined(BOOST_WINDOWS_API)
# include <windows.h>
-#endif
+#endif
#include <boost/process/stream_behavior.hpp>
#include <boost/process/environment.hpp>
@@ -39,10 +40,9 @@
/**
* Context class to define how a child process is created.
*
- * The context class is used to configure standard streams and
- * to set the work directory and environment variables. It is also
- * used to change a process name (the variable commonly known as
- * argv[0]).
+ * The context class is used to configure standard streams and to set the work
+ * directory and environment variables. It is also used to change a process
+ * name (the variable commonly known as argv[0]).
*/
struct context
{
@@ -88,20 +88,23 @@
*/
context()
#if defined(BOOST_POSIX_API)
- : stdin_behavior(behavior::inherit::def(STDIN_FILENO)),
- stdout_behavior(behavior::inherit::def(STDOUT_FILENO)),
- stderr_behavior(behavior::inherit::def(STDERR_FILENO)),
+ : stdin_behavior(behavior::inherit::create(STDIN_FILENO)),
+ stdout_behavior(behavior::inherit::create(STDOUT_FILENO)),
+ stderr_behavior(behavior::inherit::create(STDERR_FILENO)),
#elif defined(BOOST_WINDOWS_API)
- : stdin_behavior(behavior::inherit::def(GetStdHandle(STD_INPUT_HANDLE))),
- stdout_behavior(behavior::inherit::def(GetStdHandle(STD_OUTPUT_HANDLE))),
- stderr_behavior(behavior::inherit::def(GetStdHandle(STD_ERROR_HANDLE))),
+ : stdin_behavior(behavior::inherit::create(GetStdHandle(
+ STD_INPUT_HANDLE))),
+ stdout_behavior(behavior::inherit::create(GetStdHandle(
+ STD_OUTPUT_HANDLE))),
+ stderr_behavior(behavior::inherit::create(GetStdHandle(
+ STD_ERROR_HANDLE))),
#endif
work_dir(self::get_work_dir()),
environment(self::get_environment())
{
}
-#if defined(BOOST_PROCESS_DOXYGEN) || defined(BOOST_POSIX_API)
+#if defined(BOOST_PROCESS_DOXYGEN)
/**
* Setups a child process.
*
@@ -111,7 +114,11 @@
*
* On POSIX platforms setup() is called in the child process. That's why in
* a multithreaded application only async-signal-safe functions must be
- * called in setup().
+ * called in setup(). A reference to a std::vector<bool> is passed which
+ * is used to decide which file descriptors to close in the child process.
+ * While the std::vector<bool> is automatically setup for standard streams
+ * developers can change flags to avoid the library closing other file
+ * descriptors.
*
* On Windows platforms setup() is called in the parent process. A
* reference to a STARTUPINFOA structure is passed as parameter.
@@ -119,6 +126,10 @@
void setup()
{
}
+#elif defined(BOOST_POSIX_API)
+ void setup(std::vector<bool> &closeflags)
+ {
+ }
#elif defined(BOOST_WINDOWS_API)
void setup(STARTUPINFOA &sainfo)
{
Modified: sandbox/SOC/2010/process/boost/process/operations.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/operations.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/operations.hpp 2010-07-31 12:59:13 EDT \
(Sat, 31 Jul 2010) @@ -175,9 +175,9 @@
* Launches a new process based on the binary image specified by the
* executable, the set of arguments passed to it and 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.
+ * \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.
*/
@@ -218,6 +218,12 @@
BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("fork(2) failed");
else if (pid == 0)
{
+ if (chdir(ctx.work_dir.c_str()) == -1)
+ {
+ write(STDERR_FILENO, "chdir() failed\n", 15);
+ _exit(127);
+ }
+
handle hstdin = ctx.stdin_behavior->get_child_end();
if (hstdin.valid())
{
@@ -251,20 +257,14 @@
closeflags[STDERR_FILENO] = false;
}
- for (int i = 0; i < maxdescs; ++i)
+ ctx.setup(closeflags);
+
+ for (std::size_t i = 0; i < closeflags.size(); ++i)
{
if (closeflags[i])
close(i);
}
- if (chdir(ctx.work_dir.c_str()) == -1)
- {
- write(STDERR_FILENO, "chdir() failed\n", 15);
- _exit(127);
- }
-
- ctx.setup();
-
execve(executable.c_str(), argv.second, envp.second);
// Actually we should delete argv and envp data. As we must not
@@ -332,16 +332,7 @@
}
/**
- * Starts a new child process.
- *
- * Launches a new process based on the binary image specified by the
- * executable.
- *
- * \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.
+ * \overload
*/
inline child create_child(const std::string &executable)
{
@@ -349,16 +340,7 @@
}
/**
- * Starts a new child process.
- *
- * Launches a new process based on the binary image specified by the
- * executable and the set of arguments passed to it.
- *
- * \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.
+ * \overload
*/
template <typename Arguments>
inline child create_child(const std::string &executable, Arguments args)
@@ -376,17 +358,16 @@
* This function behaves similarly to the system(3) system call. In a
* POSIX system, the command is fed to /bin/sh whereas under a Windows
* system, it is fed to cmd.exe. It is difficult to write portable
- * commands as the first parameter, but this function comes in handy in
- * multiple situations.
+ * commands, but this function comes in handy in multiple situations.
*
- * \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.
+ * \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 <typename Context>
-inline child create_shell(const std::string &command, Context ctx)
+inline child shell(const std::string &command, Context ctx)
{
#if defined(BOOST_POSIX_API)
std::string executable = "/bin/sh";
@@ -407,6 +388,14 @@
return create_child(executable, args, ctx);
}
+/**
+ * \overload
+ */
+inline child shell(const std::string &command)
+{
+ return shell(command, context());
+}
+
}
}
Modified: sandbox/SOC/2010/process/boost/process/pipe.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/pipe.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/pipe.hpp 2010-07-31 12:59:13 EDT (Sat, 31 \
Jul 2010) @@ -26,11 +26,16 @@
namespace boost {
namespace process {
+#if defined(BOOST_PROCESS_DOXYGEN)
/**
- * The pipe class is a type definition for stream-based classes
- * defined by Boost.Asio.
+ * The pipe class is a type definition for stream-based classes defined by
+ * Boost.Asio.
+ *
+ * The type definition is provided for convenience. You can also use Boost.Asio
+ * classes directly for asynchronous I/O operations.
*/
-#if defined(BOOST_POSIX_API)
+typedef BoostAsioPipe pipe;
+#elif defined(BOOST_POSIX_API)
typedef boost::asio::posix::stream_descriptor pipe;
#elif defined(BOOST_WINDOWS_API)
typedef boost::asio::windows::stream_handle pipe;
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-07-31 12:59:13 EDT (Sat, \
31 Jul 2010) @@ -60,7 +60,7 @@
/**
* Creates a new process' output stream.
*/
- explicit pistream(boost::process::handle &h)
+ explicit pistream(boost::process::handle h)
: std::istream(0),
handle_(h),
systembuf_(handle_.native())
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-07-31 12:59:13 EDT (Sat, \
31 Jul 2010) @@ -60,7 +60,7 @@
/**
* Creates a new process' input stream.
*/
- explicit postream(boost::process::handle &h)
+ explicit postream(boost::process::handle h)
: std::ostream(0),
handle_(h),
systembuf_(handle_.native())
Modified: sandbox/SOC/2010/process/boost/process/stream_behavior.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/stream_behavior.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/stream_behavior.hpp 2010-07-31 12:59:13 \
EDT (Sat, 31 Jul 2010) @@ -15,7 +15,6 @@
* \file boost/process/stream_behavior.hpp
*
* Includes the declaration of stream behavior classes.
- *
*/
#ifndef BOOST_PROCESS_STREAM_BEHAVIOR_HPP
@@ -61,7 +60,7 @@
* what a context object expects. The shared pointer guarantees that
* the object is cleaned up.
*/
- static boost::shared_ptr<stream> def()
+ static boost::shared_ptr<stream> create()
{
return boost::make_shared<stream>(stream());
}
@@ -113,7 +112,7 @@
#endif
}
- static boost::shared_ptr<inherit> def(handle::native_type child_end)
+ static boost::shared_ptr<inherit> create(handle::native_type child_end)
{
return boost::make_shared<inherit>(inherit(child_end));
}
@@ -162,7 +161,7 @@
#endif
}
- static boost::shared_ptr<pipe> def(stream_type stream)
+ static boost::shared_ptr<behavior::pipe> create(stream_type stream)
{
return boost::make_shared<pipe>(pipe(stream));
}
@@ -282,7 +281,7 @@
#endif
}
- static boost::shared_ptr<named_pipe> def(stream_type stream)
+ static boost::shared_ptr<named_pipe> create(stream_type stream)
{
return boost::make_shared<named_pipe>(named_pipe(stream));
}
@@ -330,7 +329,7 @@
#endif
}
- static boost::shared_ptr<dummy> def(stream_type stream)
+ static boost::shared_ptr<dummy> create(stream_type stream)
{
return boost::make_shared<dummy>(dummy(stream));
}
Added: sandbox/SOC/2010/process/libs/process/doc/Jamfile.jam
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/doc/Jamfile.jam 2010-07-31 12:59:13 EDT \
(Sat, 31 Jul 2010) @@ -0,0 +1,34 @@
+#
+# Boost.Process
+# ~~~~~~~~~~~~~
+#
+# Copyright (c) 2006, 2007 Julio M. Merino Vidal
+# Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
+# Copyright (c) 2009 Boris Schaeling
+# Copyright (c) 2010 Felipe Tanus, Boris Schaeling
+#
+# Distributed under the Boost Software License, Version 1.0. (See accompanying
+# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#
+
+using quickbook ;
+
+doxygen autodoc
+ :
+ ../../../boost/process.hpp
+ [ glob ../../../boost/process/*.hpp ]
+ [ glob ../../../boost/process/detail/*.hpp ]
+ :
+ <doxygen:param>PREDEFINED=BOOST_PROCESS_DOXYGEN
+ ;
+
+xml process : process.qbk ;
+
+boostbook standalone
+ :
+ process
+ :
+ <dependency>autodoc
+ <xsl:param>boost.root=../../../..
+ <xsl:param>html.stylesheet=../../../../doc/src/boostbook.css
+ ;
Added: sandbox/SOC/2010/process/libs/process/doc/asyncio.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/doc/asyncio.qbk 2010-07-31 12:59:13 EDT \
(Sat, 31 Jul 2010) @@ -0,0 +1,16 @@
+[section:asyncio Asynchronous I/O]
+
+Just like the streams from the C++ standard library _pistream_ and _postream_ only \
support synchronous (or blocking) I/O. For asynchronous I/O Boost.Process provides \
the class _pipe_. +
+[import ../example/async_io.cpp]
+[async_io]
+
+Asynchronous I/O operations are based on Boost.Asio. As _pipe_ is an I/O object it \
must be initialized with an I/O service object. In order to connect the I/O object to \
a stream the handle of a stream must also be passed to the constructor of _pipe_. +
+The _handle_ class is a wrapper for a file descriptor on POSIX and a HANDLE on \
Windows systems. Boost.Process provides the class to avoid leaking handles as the \
destructor closes them automatically. As both objects of type _handle_ and _pipe_ own \
handles _handle_release_ must be called to pass ownership of the native handle from \
the _handle_ instance to the _pipe_ instance. +
+Once the _pipe_ instance has been created and setup asynchronous I/O operations can \
be used. +
+[note _pipe_ is a `typedef` for `boost::asio::posix::stream_descriptor` on POSIX and \
`boost::asio::windows::stream_handle` on Windows systems.] +
+[endsect]
Added: sandbox/SOC/2010/process/libs/process/doc/childprocess.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/doc/childprocess.qbk 2010-07-31 12:59:13 \
EDT (Sat, 31 Jul 2010) @@ -0,0 +1,23 @@
+[section:childprocess Creating child processes]
+
+Boost.Process provides the free-standing function _create_child_ to create child \
processes. You only need to pass the name of an executable as a `std::string`. +
+[import ../example/create_child_overloads.cpp]
+[create_child_overloads_exe]
+
+The above example will throw an exception of type `boost::system::system_error` if \
no executable hostname is found in the current work directory. _create_child_ does \
not automatically search the filesystem for an executable. If you know the executable \
is not in the current work directory you must add the path (either relative or \
absolute). +
+If you know the executable can be found in the directories of the environment \
variable PATH you can call _find_executable_in_path_. This function returns the \
absolute path to the executable. If it can't find the executable in PATH it throws \
`boost::filesystem::filesystem_error`. +
+[create_child_overloads_exe_in_path]
+
+Additionally you can pass command line options to _create_child_. While the command \
line options must be of type `std::string` you can store them in any STL container. \
+ +[create_child_overloads_args]
+
+If you like to run a command on the shell you can use another free-standing function \
_shell_. +
+[import ../example/shell.cpp]
+[shell]
+
+[endsect]
Added: sandbox/SOC/2010/process/libs/process/doc/communication.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/doc/communication.qbk 2010-07-31 12:59:13 \
EDT (Sat, 31 Jul 2010) @@ -0,0 +1,15 @@
+[section:communicating Communicating with child processes]
+
+The two most interesting stream behaviors are _behavior_pipe_ and \
_behavior_named_pipe_. You use them to exchange data between a parent and a child \
process. +
+[create_child_context_pipe]
+
+It depends on the stream behavior classes whether parameters can be passed to \
constructors. _behavior_pipe_ requires a parameter as it needs to know whether the \
pipe will be attached to an input or output stream of the child process. +
+If a parent process wants to communicate with a child process the return value of \
_create_child_ should not be discarded. The return value of type _child_ provides \
access to the newly created child process. Among others, the member functions \
_child_get_stdin_, _child_get_stdout_ and _child_get_stderr_ are provided to access \
the other ends of the child process' standard streams. +
+[caution You must not call _child_get_stdin_, _child_get_stdout_ and \
_child_get_stderr_ if you didn't configure the standard streams to be redirected to \
the parent process.] +
+The streams returned by _child_get_stdin_, _child_get_stdout_ and _child_get_stderr_ \
are used similarly to streams from the C++ standard library. The type of the return \
values is either _pistream_ and _postream_ (depending on whether they are input or \
output streams). These classes are derived from `std::istream` and `std::ostream` and \
provide two additional member functions `close()` and `handle()`. You use the latter \
member function for asynchronous I/O. +
+[endsect]
Added: sandbox/SOC/2010/process/libs/process/doc/context.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/doc/context.qbk 2010-07-31 12:59:13 EDT \
(Sat, 31 Jul 2010) @@ -0,0 +1,28 @@
+[section:context Configuring runtime contexts]
+
+Apart from the executable name and command line options a third parameter can be \
passed to _create_child_: The _context_ class is used to configure the runtime \
context of a new process. +
+The _context_ class provides only a few member variables. You can set the process \
name with `context::process_name`, the work directory with `context::work_dir` and \
environment variables with `context::environment`. +
+[import ../example/create_child_context.cpp]
+[create_child_context_configuration]
+
+In practice you are probably more often using the member variables \
`context::stdin_behavior`, `context::stdout_behavior` and `context::stderr_behavior`. \
It depends on these settings how the standard streams of a child process will be \
configured. +
+The type of these three member variables is \
`boost::shared_ptr<boost::process::behavior::stream>`. _behavior_stream_ is the base \
class of a small hierarchy of behavior classes. Boost.Process provides the following \
stream behavior classes: +
+* _behavior_close_
+* _behavior_inherit_
+* _behavior_pipe_
+* _behavior_named_pipe_
+* _behavior_dummy_
+
+It depends on these classes if and how a standard stream can be used by a child \
process. As it is a class hierarchy you are free to derive your own classes and [link \
boost_process.extension_points define new stream behaviors]. +
+By default, standard streams are inherited. If you want to configure standard \
streams differently create an instance of a stream behavior class and assign it. For \
convenience all behavior classes provide a _behavior_stream_create_ member function \
which returns an instance of a stream behavior owned by `boost::shared_ptr`. +
+[create_child_context_dummy]
+
+In the code above the behavior of the standard output stream is changed. Instead of \
inheriting the standard output stream data written to it will be discarded. The \
stream is not closed by _behavior_dummy_ but any data is ignored. +
+[endsect]
Added: sandbox/SOC/2010/process/libs/process/doc/posix.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/doc/posix.qbk 2010-07-31 12:59:13 EDT (Sat, \
31 Jul 2010) @@ -0,0 +1,25 @@
+[section:posix POSIX extensions]
+
+_context_setup_ is an extension point to setup a child process calling platform \
specific functions. On POSIX systems _context_setup_ is invoked after _fork_ has been \
called but before _execve_ is called. _context_setup_ is executed within the child \
process only. +
+In order to inject code into _context_setup_ a new context class has to be defined \
and derived from _context_. Then one can call for example _chroot_ to change the root \
directory of the new process. +
+[import ../example/chroot_setup.cpp]
+[chroot_setup_context]
+
+The new `context` class is used like _context_.
+
+[chroot_setup_main]
+
+[caution When you override _context_setup_ in a multi-threaded application you must \
not call any function which is not async-signal-safe. Calling non-async-signal-safe \
functions between _fork_ and _execve_ is undefined behavior in multi-threaded \
applications. If you must call non-async-signal-safe functions prior to calling \
_execve_ (because you want to change the root directory with _chroot_ for example) \
you must create a singlethreaded wrapper process which can safely call \
non-async-signal-safe function. For more information have a look at the man page of \
_fork_.] +
+As you see in the example above a reference to a `std::vector<bool>` is passed to \
_context_setup_. The flags are used to configure which file descriptors should be \
closed before _execve_ is called. The flags at the indexes 0, 1 and 2 are set \
according to the standard stream behaviors. If the child process should inherit \
additional file descriptors you can change the flags. +
+[import ../example/file_descriptors_setup.cpp]
+[file_descriptors_context]
+
+This example uses the D-Bus message bus daemon to write data to the file descriptors \
3 and 4. In order to read the data in the parent process those file descriptors not \
only must not be closed. The parent process must also use stream objects and \
initialize them with the read ends of the pipes. +
+[file_descriptors_main]
+
+[endsect]
Added: sandbox/SOC/2010/process/libs/process/doc/preface.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/doc/preface.qbk 2010-07-31 12:59:13 EDT \
(Sat, 31 Jul 2010) @@ -0,0 +1,22 @@
+[section:preface Preface]
+
+Boost.Process is a library to manage system processes. It can be used to:
+
+* create child processes
+* run shell commands
+* setup environment variables for child processes
+* setup standard streams for child processes
+* communicate with child processes through standard streams (synchronously or \
asynchronously) +* wait for processes to exit (synchronously or asynchronously)
+* terminate processes
+
+While Boost.Process does not support platform specific features it provides \
extension points. Developers can plug in functions, eg. to set the `uid` of a child \
process on a POSIX system. +
+Here's an example of how easy it is to start a program with Boost.Process.
+
+[import ../example/create_child.cpp]
+[create_child]
+
+The example searches for an executable hostname in the directories of the enviroment \
variable PATH and starts it. As the standard output stream is inherited the hostname \
is printed when you run the example. +
+[endsect]
Added: sandbox/SOC/2010/process/libs/process/doc/process.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/doc/process.qbk 2010-07-31 12:59:13 EDT \
(Sat, 31 Jul 2010) @@ -0,0 +1,63 @@
+[library Boost.Process
+ [quickbook 1.5]
+ [authors [Schaeling, Boris], [Tanus, Felipe]]
+ [copyright 2006, 2007, 2008, 2009, 2010 Julio M. Merino Vidal, Boris Schaeling, \
Ilya Sokolov, Felipe Tanus] + [id process]
+ [dirname process]
+ [license
+ 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)
+ ]
+]
+
+[def _fork_ [@http://www.opengroup.org/onlinepubs/000095399/functions/fork.html \
`fork`]] +[def _execve_ \
[@http://www.opengroup.org/onlinepubs/009695399/functions/exec.html `execve`]] +[def \
_chroot_ [@http://opengroup.org/onlinepubs/007908799/xsh/chroot.html `chroot`]] +[def \
_createprocess_ [@http://msdn.microsoft.com/en-us/library/ms682425(VS.85).aspx \
`CreateProcess`]] +[def _sys/wait.h_ \
[@http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/wait.h.html \
`sys/wait.h`]] +[def _child_ [classref boost::process::child `child`]]
+[def _context_ [classref boost::process::context `context`]]
+[def _handle_ [classref boost::process::handle `handle`]]
+[def _pipe_ [classref boost::process::pipe `pipe`]]
+[def _pistream_ [classref boost::process::pistream `pistream`]]
+[def _postream_ [classref boost::process::postream `postream`]]
+[def _status_ [classref boost::process::status `status`]]
+[def _behavior_stream_ [classref boost::process::behavior::stream \
`behavior::stream`]] +[def _behavior_close_ [classref boost::process::behavior::close \
`behavior::close`]] +[def _behavior_inherit_ [classref \
boost::process::behavior::inherit `behavior::inherit`]] +[def _behavior_pipe_ \
[classref boost::process::behavior::pipe `behavior::pipe`]] +[def \
_behavior_named_pipe_ [classref boost::process::behavior::named_pipe \
`behavior::named_pipe`]] +[def _behavior_dummy_ [classref \
boost::process::behavior::dummy `behavior::dummy`]] +[def _behavior_stream_create_ \
[memberref boost::process::behavior::stream::create `behavior::stream::create()`]] \
+[def _behavior_stream_get_child_end_ [memberref \
boost::process::behavior::stream::get_child_end `behavior::stream::get_child_end()`]] \
+[def _behavior_stream_get_parent_end_ [memberref \
boost::process::behavior::stream::get_parent_end \
`behavior::stream::get_parent_end()`]] +[def _child_get_stdin_ [memberref \
boost::process::child::get_stdin `child::get_stdin()`]] +[def _child_get_stdout_ \
[memberref boost::process::child::get_stdout `child::get_stdout()`]] +[def \
_child_get_stderr_ [memberref boost::process::child::get_stderr \
`child::get_stderr()`]] +[def _child_wait_ [memberref boost::process::process::wait \
`child::wait()`]] +[def _child_terminate_ [memberref \
boost::process::process::terminate `child::terminate()`]] +[def _context_setup_ \
[memberref boost::process::context::setup `context::setup()`]] +[def _handle_release_ \
[memberref boost::process::handle::release `handle::release()`]] +[def \
_status_async_wait_ [memberref boost::process::detail::basic_status::async_wait \
`status::async_wait()`]] +[def _create_child_ [funcref boost::process::create_child \
`create_child()`]] +[def _shell_ [funcref boost::process::shell `shell()`]]
+[def _find_executable_in_path_ [funcref boost::process::find_executable_in_path \
`find_executable_in_path()`]] +
+[include preface.qbk]
+
+[section User Guide]
+
+[include childprocess.qbk]
+[include context.qbk]
+[include communication.qbk]
+[include asyncio.qbk]
+[include waiting.qbk]
+[include terminating.qbk]
+[include userstreambehaviors.qbk]
+[include posix.qbk]
+[include windows.qbk]
+
+[endsect]
+
+[xinclude autodoc.xml]
Added: sandbox/SOC/2010/process/libs/process/doc/terminating.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/doc/terminating.qbk 2010-07-31 12:59:13 EDT \
(Sat, 31 Jul 2010) @@ -0,0 +1,8 @@
+[section:terminating Terminating a process]
+
+If you don't want to wait for a process to exit you can call _child_terminate_ to \
terminate a process. +
+[import ../example/terminate.cpp]
+[terminate]
+
+[endsect]
Added: sandbox/SOC/2010/process/libs/process/doc/userstreambehaviors.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/doc/userstreambehaviors.qbk 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010) @@ -0,0 +1,18 @@
+[section:user_stream_behaviors Creating new stream behaviors]
+
+When creating a child process its standard streams must be configured. By default, \
standard streams are inherited. Boost.Process provides various stream behaviors to \
change the default configuration. However as developers might want to do something \
else with standard streams it's possible to create new stream behaviors. +
+In order to create a new stream behavior a class must be derived from \
_behavior_stream_. There are two virtual member functions inherited which can be \
overridden: _behavior_stream_get_child_end_ and _behavior_stream_get_parent_end_. \
These functions return the stream ends for the child and the parent process. The type \
of the stream ends is _handle_. +
+The following code defines a stream behavior class `redirect_to` which can be used \
to redirect streams. +
+[import ../example/redirect_to.cpp]
+[redirect_to_stream]
+
+[caution When you create a stream behavior like `redirect_to` whose constructor \
expects a handle as a parameter don't save the handle directly. If an existing handle \
should be reused it must be duplicated. Stream behavior instances own resources and \
must not share handles.] +
+The following program uses `redirect_to` to redirect the standard error stream of a \
child process to its standard output stream. +
+[redirect_to_main]
+
+[endsect]
Added: sandbox/SOC/2010/process/libs/process/doc/waiting.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/doc/waiting.qbk 2010-07-31 12:59:13 EDT \
(Sat, 31 Jul 2010) @@ -0,0 +1,19 @@
+[section:waiting Waiting for a process to exit]
+
+_child_ provides the member function _child_wait_ to wait for a process to exit.
+
+[import ../example/sync_wait.cpp]
+[sync_wait]
+
+[caution On POSIX systems you must use the macros defined in _sys/wait.h_ to \
interpret exit codes.] +
+_child_ does not provide any member function to wait asynchronously as Boost.Process \
follows Boost.Asio guidelines. Instead _status_ must be used to create an I/O object. \
+
+[import ../example/async_wait.cpp]
+[async_wait]
+
+By passing a process ID to _status_async_wait_ an asynchronous wait operation is \
initiated. As _status_async_wait_ expects a process ID _status_ is loosely coupled \
with other components of Boost.Process. Even if you don't create processes with \
_create_child_ you can use _status_ to wait asynchronously as long as you have a \
process ID. +
+[note The type of the process ID is `boost::process::pid_type`. It is a `typedef` \
for `pid_t` on POSIX and `DWORD` on Windows platforms.] +
+[endsect]
Added: sandbox/SOC/2010/process/libs/process/doc/windows.qbk
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/doc/windows.qbk 2010-07-31 12:59:13 EDT \
(Sat, 31 Jul 2010) @@ -0,0 +1,12 @@
+[section:windows Windows extensions]
+
+_context_setup_ can be used to configure a child process using Windows specific \
options. On Windows a reference to a `STARTUPINFOA` object is passed to \
_context_setup_. If a new context class is created and derived from _context_ the \
`STARTUPINFOA` object which is used by Boost.Process to start a new process can be \
configured. +
+[import ../example/startupinfo_setup.cpp]
+[startupinfo_setup_context]
+
+The `context` class sets window position and size as a hint. It can be used to lanch \
Notepad for example. +
+[startupinfo_setup_main]
+
+[endsect]
Added: sandbox/SOC/2010/process/libs/process/example/Jamfile.jam
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/example/Jamfile.jam 2010-07-31 12:59:13 EDT \
(Sat, 31 Jul 2010) @@ -0,0 +1,32 @@
+#
+# Boost.Process
+# ~~~~~~~~~~~~~
+#
+# Copyright (c) 2006, 2007 Julio M. Merino Vidal
+# Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
+# Copyright (c) 2009 Boris Schaeling
+# Copyright (c) 2010 Felipe Tanus, Boris Schaeling
+#
+# Distributed under the Boost Software License, Version 1.0. (See accompanying
+# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#
+
+project : requirements
+ <include>../../..
+ <target-os>windows:<define>WIN32_LEAN_AND_MEAN
+ ;
+
+using testing ;
+
+compile async_io.cpp ;
+compile async_wait.cpp ;
+compile chroot_setup.cpp ;
+compile create_child.cpp ;
+compile create_child_context.cpp ;
+compile create_child_overloads.cpp ;
+compile file_descriptors_setup.cpp ;
+compile redirect_to.cpp ;
+compile shell.cpp ;
+compile startupinfo_setup.cpp ;
+compile sync_wait.cpp ;
+compile terminate.cpp ;
Added: sandbox/SOC/2010/process/libs/process/example/async_io.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/example/async_io.cpp 2010-07-31 12:59:13 \
EDT (Sat, 31 Jul 2010) @@ -0,0 +1,48 @@
+//
+// Boost.Process
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2006, 2007 Julio M. Merino Vidal
+// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
+// Copyright (c) 2009 Boris Schaeling
+// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#include <boost/process/all.hpp>
+#include <boost/asio.hpp>
+#include <boost/array.hpp>
+#include <string>
+#include <vector>
+#include <iostream>
+
+//[async_io
+boost::asio::io_service ioservice;
+boost::array<char, 4096> buf;
+
+void handler(const boost::system::error_code &ec,
+ std::size_t bytes_transferred);
+
+int main()
+{
+ std::string exe = boost::process::find_executable_in_path("hostname");
+ std::vector<std::string> args;
+ boost::process::context ctx;
+ ctx.stdout_behavior = boost::process::behavior::named_pipe::create(
+ boost::process::behavior::named_pipe::output_stream);
+ boost::process::child c = boost::process::create_child(exe, args, ctx);
+ boost::process::pistream &is = c.get_stdout();
+ boost::process::handle h = is.handle();
+ boost::process::pipe read_end(ioservice, h.release());
+ read_end.async_read_some(boost::asio::buffer(buf), handler);
+ ioservice.run();
+}
+
+void handler(const boost::system::error_code &ec,
+ std::size_t bytes_transferred)
+{
+ std::cout << std::string(buf.data(), bytes_transferred) << std::flush;
+}
+//]
Added: sandbox/SOC/2010/process/libs/process/example/async_wait.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/example/async_wait.cpp 2010-07-31 12:59:13 \
EDT (Sat, 31 Jul 2010) @@ -0,0 +1,50 @@
+//
+// Boost.Process
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2006, 2007 Julio M. Merino Vidal
+// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
+// Copyright (c) 2009 Boris Schaeling
+// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#include <boost/process/all.hpp>
+#include <boost/asio.hpp>
+#include <string>
+#include <vector>
+#include <iostream>
+
+#if defined(BOOST_POSIX_API)
+# include <sys/wait.h>
+#endif
+
+//[async_wait
+boost::asio::io_service ioservice;
+
+void end_wait(const boost::system::error_code &ec, int exit_code);
+
+int main()
+{
+ std::string exe = boost::process::find_executable_in_path("hostname");
+ std::vector<std::string> args;
+ boost::process::child c = boost::process::create_child(exe, args);
+ boost::process::status s(ioservice);
+ s.async_wait(c.get_id(), end_wait);
+ ioservice.run();
+}
+
+void end_wait(const boost::system::error_code &ec, int exit_code)
+{
+ if (!ec)
+ {
+#if defined(BOOST_POSIX_API)
+ if (WIFEXITED(exit_code))
+ exit_code = WEXITSTATUS(exit_code);
+#endif
+ std::cout << "exit code: " << exit_code << std::endl;
+ }
+}
+//]
Added: sandbox/SOC/2010/process/libs/process/example/chroot_setup.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/example/chroot_setup.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010) @@ -0,0 +1,43 @@
+//
+// Boost.Process
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2006, 2007 Julio M. Merino Vidal
+// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
+// Copyright (c) 2009 Boris Schaeling
+// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#include <boost/process/all.hpp>
+
+#if defined(BOOST_POSIX_API)
+
+#include <string>
+#include <vector>
+#include <unistd.h>
+
+//[chroot_setup_context
+class context : public boost::process::context
+{
+public:
+ void setup(std::vector<bool> &closeflags)
+ {
+ chroot("/tmp");
+ }
+};
+//]
+
+int main()
+{
+//[chroot_setup_main
+ std::string exe = boost::process::find_executable_in_path("hostname");
+ std::vector<std::string> args;
+ context ctx;
+ boost::process::create_child(exe, args, ctx);
+//]
+}
+
+#endif
Added: sandbox/SOC/2010/process/libs/process/example/create_child.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/example/create_child.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010) @@ -0,0 +1,23 @@
+//
+// Boost.Process
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2006, 2007 Julio M. Merino Vidal
+// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
+// Copyright (c) 2009 Boris Schaeling
+// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+//[create_child
+#include <boost/process/all.hpp>
+#include <string>
+
+int main()
+{
+ std::string exe = boost::process::find_executable_in_path("hostname");
+ boost::process::create_child(exe);
+}
+//]
Added: sandbox/SOC/2010/process/libs/process/example/create_child_context.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/example/create_child_context.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010) @@ -0,0 +1,64 @@
+//
+// Boost.Process
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2006, 2007 Julio M. Merino Vidal
+// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
+// Copyright (c) 2009 Boris Schaeling
+// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#include <boost/process/all.hpp>
+#include <string>
+#include <vector>
+#include <utility>
+#include <iostream>
+
+void create_child_context_configuration()
+{
+//[create_child_context_configuration
+ std::string exe = boost::process::find_executable_in_path("hostname");
+ std::vector<std::string> args;
+ boost::process::context ctx;
+ ctx.process_name = "hostname";
+ ctx.work_dir = "C:\\";
+ ctx.environment.insert(std::make_pair("new_variable", "value"));
+ boost::process::create_child(exe, args, ctx);
+//]
+}
+
+void create_child_context_dummy()
+{
+//[create_child_context_dummy
+ std::string exe = boost::process::find_executable_in_path("hostname");
+ std::vector<std::string> args;
+ boost::process::context ctx;
+ ctx.stdout_behavior = boost::process::behavior::dummy::create(
+ boost::process::behavior::dummy::output_stream);
+ boost::process::create_child(exe, args, ctx);
+//]
+}
+
+void create_child_context_pipe()
+{
+//[create_child_context_pipe
+ std::string exe = boost::process::find_executable_in_path("hostname");
+ std::vector<std::string> args;
+ boost::process::context ctx;
+ ctx.stdout_behavior = boost::process::behavior::pipe::create(
+ boost::process::behavior::pipe::output_stream);
+ boost::process::child c = boost::process::create_child(exe, args, ctx);
+ boost::process::pistream &is = c.get_stdout();
+ std::cout << is.rdbuf() << std::flush;
+//]
+}
+
+int main()
+{
+ create_child_context_configuration();
+ create_child_context_dummy();
+ create_child_context_pipe();
+}
Added: sandbox/SOC/2010/process/libs/process/example/create_child_overloads.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/example/create_child_overloads.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010) @@ -0,0 +1,48 @@
+//
+// Boost.Process
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2006, 2007 Julio M. Merino Vidal
+// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
+// Copyright (c) 2009 Boris Schaeling
+// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#include <boost/process/all.hpp>
+#include <boost/assign/list_of.hpp>
+#include <string>
+#include <vector>
+
+void create_child()
+{
+//[create_child_overloads_exe
+ boost::process::create_child("hostname");
+//]
+}
+
+void create_child_find_exe()
+{
+//[create_child_overloads_exe_in_path
+ std::string exe = boost::process::find_executable_in_path("hostname");
+ boost::process::create_child(exe);
+//]
+}
+
+void create_child_args()
+{
+//[create_child_overloads_args
+ std::string exe = boost::process::find_executable_in_path("hostname");
+ std::vector<std::string> args = boost::assign::list_of("-?");
+ boost::process::create_child(exe, args);
+//]
+}
+
+int main()
+{
+ create_child();
+ create_child_find_exe();
+ create_child_args();
+}
Deleted: sandbox/SOC/2010/process/libs/process/example/create_process.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/example/create_process.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010)
+++ (empty file)
@@ -1,33 +0,0 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include <boost/process/all.hpp>
-#include <boost/assign/list_of.hpp>
-#include <vector>
-#include <string>
-#include <utility>
-
-using namespace boost::process;
-
-int main()
-{
- child c1 = create_child(find_executable_in_path("hostname"));
-
- std::vector<std::string> args = boost::assign::list_of("-?");
- child c2 = create_child(find_executable_in_path("hostname"), args);
-
- context ctx;
- ctx.environment.insert(std::make_pair("NEW_ENV_VARIABLE", "VALUE"));
- ctx.stdin_behavior = behavior::close::def();
- ctx.stdout_behavior = behavior::close::def();
- child c3 = create_child(find_executable_in_path("hostname"), args, ctx);
-}
Added: sandbox/SOC/2010/process/libs/process/example/file_descriptors_setup.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/example/file_descriptors_setup.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010) @@ -0,0 +1,69 @@
+//
+// Boost.Process
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2006, 2007 Julio M. Merino Vidal
+// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
+// Copyright (c) 2009 Boris Schaeling
+// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#include <boost/process/all.hpp>
+
+#if defined(BOOST_POSIX_API)
+
+#include <boost/assign/list_of.hpp>
+#include <string>
+#include <vector>
+#include <iostream>
+#include <unistd.h>
+
+//[file_descriptors_context
+boost::process::behavior::pipe address(
+ boost::process::behavior::pipe::output_stream);
+boost::process::behavior::pipe pid(
+ boost::process::behavior::pipe::output_stream);
+
+class context : public boost::process::context
+{
+public:
+ void setup(std::vector<bool> &closeflags)
+ {
+ if (dup2(address.get_child_end().native(), 3) == -1)
+ {
+ write(STDERR_FILENO, "dup2() failed\n", 14);
+ _exit(127);
+ }
+ closeflags[3] = false;
+
+ if (dup2(pid.get_child_end().native(), 4) == -1)
+ {
+ write(STDERR_FILENO, "dup2() failed\n", 14);
+ _exit(127);
+ }
+ closeflags[4] = false;
+ }
+};
+//]
+
+int main()
+{
+//[file_descriptors_main
+ std::string exe = boost::process::find_executable_in_path("dbus-daemon");
+ std::vector<std::string> args = boost::assign::list_of("--fork")
+ ("--session")("--print-address=3")("--print-pid=4");
+ context ctx;
+ boost::process::create_child(exe, args, ctx);
+ address.get_child_end().close();
+ pid.get_child_end().close();
+ boost::process::pistream isaddress(address.get_parent_end());
+ std::cout << isaddress.rdbuf() << std::endl;
+ boost::process::pistream ispid(pid.get_parent_end());
+ std::cout << ispid.rdbuf() << std::endl;
+//]
+}
+
+#endif
Deleted: sandbox/SOC/2010/process/libs/process/example/process_factory.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/example/process_factory.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010)
+++ (empty file)
@@ -1,25 +0,0 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include <boost/process/all.hpp>
-#include <boost/assign/list_of.hpp>
-#include <string>
-#include <utility>
-
-using namespace boost::process;
-
-int main()
-{
- process_factory f("C:\\Windows\\notepad.exe");
- f.environment.insert(std::make_pair("NEW_ENV_VARIABLE", "VALUE"));
- child = f.create();
-}
Deleted: sandbox/SOC/2010/process/libs/process/example/read_async_from_child.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/example/read_async_from_child.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010)
+++ (empty file)
@@ -1,42 +0,0 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include <boost/asio.hpp>
-#include <boost/process/all.hpp>
-#include <boost/array.hpp>
-#include <string>
-#include <iostream>
-
-using namespace boost::process;
-using namespace boost::asio;
-
-io_service ioservice;
-boost::array<char, 4096> buf;
-
-void handler(const boost::system::error_code &ec, std::size_t bytes_transferred);
-
-int main()
-{
- std::string exe = find_executable_in_path("hostname");
- context ctx;
- ctx.stdout_behavior = \
behavior::named_pipe::def(behavior::named_pipe::output_stream);
- child c = create_child(exe, ctx);
- pistream &is = c.get_stdout();
- pipe read_end(ioservice, is.native().release());
- read_end.async_read_some(buffer(buf), handler);
- ioservice.run();
-}
-
-void handler(const boost::system::error_code &ec, std::size_t bytes_transferred)
-{
- std::cout << std::string(buf.data(), bytes_transferred) << std::flush;
-}
Deleted: sandbox/SOC/2010/process/libs/process/example/read_async_from_parent.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/example/read_async_from_parent.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010)
+++ (empty file)
@@ -1,50 +0,0 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include <boost/all/process.hpp>
-#include <boost/asio.hpp>
-#include <boost/array.hpp>
-#include <boost/bind.hpp>
-#include <string>
-#include <iostream>
-
-using namespace boost::process;
-using namespace boost::asio;
-
-io_service ioservice;
-boost::array<char, 4096> buf;
-
-void begin_read(pipe &read_end);
-void end_read(const boost::system::error_code &ec, std::size_t bytes_transferred, \
pipe &read_end);
-
-int main()
-{
- parent p;
- pistream &is = p.get_stdout();
- pipe read_end(ioservice, is.native());
- begin_read(read_end);
- ioservice.run();
-}
-
-void begin_read(pipe &read_end)
-{
- read_end.async_read_some(buffer(buf), boost::bind(&end_read, \
placeholders::error, placeholders::bytes_transferred, read_end));
-}
-
-void end_read(const boost::system::error_code &ec, std::size_t bytes_transferred, \
pipe &read_end)
-{
- if (!ec)
- {
- std::cout << std::string(buf.data(), bytes_transferred) << std::flush;
- begin_read(read_end);
- }
-}
Deleted: sandbox/SOC/2010/process/libs/process/example/read_from_child.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/example/read_from_child.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010)
+++ (empty file)
@@ -1,28 +0,0 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include <boost/all/process.hpp>
-#include <string>
-#include <iostream>
-
-using namespace boost::process;
-
-int main()
-{
- std::string exe = find_executable_in_path("hostname");
- context ctx;
- ctx.stdout_behavior = \
behavior::pipe::def(behavior::pipe::stream_type::output_stream);
- child c = create_child(exe, ctx);
- pistream &is = c.get_stdout();
- std::cout << is.rdbuf();
- c.wait();
-}
Deleted: sandbox/SOC/2010/process/libs/process/example/read_from_parent.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/example/read_from_parent.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010)
+++ (empty file)
@@ -1,23 +0,0 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include <boost/all/process.hpp>
-#include <iostream>
-
-using namespace boost::process;
-
-int main()
-{
- parent p;
- pistream &is = p.get_stdout();
- std::cout << is.rdbuf();
-}
Deleted: sandbox/SOC/2010/process/libs/process/example/read_info_from_process.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/example/read_info_from_process.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010)
+++ (empty file)
@@ -1,31 +0,0 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include <boost/process/all.hpp>
-#include <boost/foreach.hpp>
-#include <vector>
-#include <iterator>
-#include <iostream>
-
-using namespace boost::process;
-
-int main()
-{
- std::vector<process> processes;
-
- options opts;
- opts.children_only = true;
- create_snapshot(std::back_inserter(processes), opts);
-
- BOOST_FOREACH(process &p, processes)
- std::cout << p.name() << std::endl;
-}
Deleted: sandbox/SOC/2010/process/libs/process/example/read_sync_from_child.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/example/read_sync_from_child.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010)
+++ (empty file)
@@ -1,29 +0,0 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include <boost/process/all.hpp>
-#include <string>
-#include <iostream>
-
-using namespace boost::process;
-
-int main()
-{
- std::string exe = find_executable_in_path("hostname");
- context ctx;
- ctx.stdout_behavior = behavior::pipe::def(behavior::pipe::output_stream);
- child c = create_child(exe, ctx);
- pistream &is = c.get_stdout();
- std::string hostname;
- is >> hostname;
- std::cout << hostname << std::endl;
-}
Added: sandbox/SOC/2010/process/libs/process/example/redirect_to.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/example/redirect_to.cpp 2010-07-31 12:59:13 \
EDT (Sat, 31 Jul 2010) @@ -0,0 +1,84 @@
+//
+// Boost.Process
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2006, 2007 Julio M. Merino Vidal
+// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
+// Copyright (c) 2009 Boris Schaeling
+// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#include <boost/process/all.hpp>
+
+#if defined(BOOST_POSIX_API)
+# include <unistd.h>
+#elif defined(BOOST_WINDOWS_API)
+# include <windows.h>
+#else
+# error "Unsupported platform."
+#endif
+
+#include <boost/shared_ptr.hpp>
+#include <boost/make_shared.hpp>
+#include <iostream>
+#include <stdexcept>
+
+//[redirect_to_stream
+class redirect_to : public boost::process::behavior::stream
+{
+public:
+ redirect_to(boost::process::handle child_end)
+ {
+#if defined(BOOST_POSIX_API)
+ child_end_ = dup(child_end.native());
+ if (!child_end_.valid())
+ throw std::runtime_error("dup(2) failed");
+#elif defined(BOOST_WINDOWS_API)
+ HANDLE h;
+ if (!DuplicateHandle(GetCurrentProcess(), child_end.native(),
+ GetCurrentProcess(), &h, 0, TRUE, DUPLICATE_SAME_ACCESS))
+ throw std::runtime_error("DuplicateHandle() failed");
+ child_end_ = h;
+#endif
+ }
+
+ static boost::shared_ptr<redirect_to> create(
+ boost::process::handle stream_end)
+ {
+ return boost::make_shared<redirect_to>(redirect_to(stream_end));
+ }
+
+ boost::process::handle get_child_end()
+ {
+ return child_end_;
+ }
+
+private:
+ boost::process::handle child_end_;
+};
+//]
+
+//[redirect_to_main
+int main()
+{
+ std::string executable = boost::process::find_executable_in_path(
+ "hostname");
+
+ std::vector<std::string> args;
+
+ boost::process::context ctx;
+ ctx.stdout_behavior = boost::process::behavior::pipe::create(
+ boost::process::behavior::pipe::output_stream);
+ ctx.stderr_behavior = redirect_to::create(
+ ctx.stdout_behavior->get_child_end());
+
+ boost::process::child c = boost::process::create_child(
+ executable, args, ctx);
+
+ boost::process::pistream &is = c.get_stdout();
+ std::cout << is.rdbuf() << std::flush;
+}
+//]
Added: sandbox/SOC/2010/process/libs/process/example/shell.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/example/shell.cpp 2010-07-31 12:59:13 EDT \
(Sat, 31 Jul 2010) @@ -0,0 +1,21 @@
+//
+// Boost.Process
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2006, 2007 Julio M. Merino Vidal
+// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
+// Copyright (c) 2009 Boris Schaeling
+// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#include <boost/process/all.hpp>
+
+int main()
+{
+//[shell
+ boost::process::shell("mkdir test");
+//]
+}
Added: sandbox/SOC/2010/process/libs/process/example/startupinfo_setup.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/example/startupinfo_setup.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010) @@ -0,0 +1,46 @@
+//
+// Boost.Process
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2006, 2007 Julio M. Merino Vidal
+// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
+// Copyright (c) 2009 Boris Schaeling
+// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#include <boost/process/all.hpp>
+
+#if defined(BOOST_WINDOWS_API)
+
+#include <string>
+#include <vector>
+
+//[startupinfo_setup_context
+class context : public boost::process::context
+{
+public:
+ void setup(STARTUPINFOA &sainfo)
+ {
+ sainfo.dwFlags |= STARTF_USEPOSITION | STARTF_USESIZE;
+ sainfo.dwX = 0;
+ sainfo.dwY = 0;
+ sainfo.dwXSize = 640;
+ sainfo.dwYSize = 480;
+ }
+};
+//]
+
+//[startupinfo_setup_main
+int main()
+{
+ std::string exe = boost::process::find_executable_in_path("notepad");
+ std::vector<std::string> args;
+ context ctx;
+ boost::process::create_child(exe, args, ctx);
+}
+//]
+
+#endif
Added: sandbox/SOC/2010/process/libs/process/example/sync_wait.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/example/sync_wait.cpp 2010-07-31 12:59:13 \
EDT (Sat, 31 Jul 2010) @@ -0,0 +1,34 @@
+//
+// Boost.Process
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2006, 2007 Julio M. Merino Vidal
+// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
+// Copyright (c) 2009 Boris Schaeling
+// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#include <boost/process/all.hpp>
+#include <string>
+#include <iostream>
+
+#if defined(BOOST_POSIX_API)
+# include <sys/wait.h>
+#endif
+
+//[sync_wait
+int main()
+{
+ std::string exe = boost::process::find_executable_in_path("hostname");
+ boost::process::child c = boost::process::create_child(exe);
+ int exit_code = c.wait();
+#if defined(BOOST_POSIX_API)
+ if (WIFEXITED(exit_code))
+ exit_code = WEXITSTATUS(exit_code);
+#endif
+ std::cout << exit_code << std::endl;
+}
+//]
Added: sandbox/SOC/2010/process/libs/process/example/terminate.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/example/terminate.cpp 2010-07-31 12:59:13 \
EDT (Sat, 31 Jul 2010) @@ -0,0 +1,24 @@
+//
+// Boost.Process
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2006, 2007 Julio M. Merino Vidal
+// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
+// Copyright (c) 2009 Boris Schaeling
+// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#include <boost/process/all.hpp>
+#include <string>
+
+int main()
+{
+//[terminate
+ std::string exe = boost::process::find_executable_in_path("hostname");
+ boost::process::child c = boost::process::create_child(exe);
+ c.terminate();
+//]
+}
Deleted: sandbox/SOC/2010/process/libs/process/example/terminate_child.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/example/terminate_child.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010)
+++ (empty file)
@@ -1,23 +0,0 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include <boost/all/process.hpp>
-#include <string>
-
-using namespace boost::process;
-
-int main()
-{
- std::string exe = find_executable_in_path("hostname");
- child c = create_child(exe);
- c.terminate();
-}
Deleted: sandbox/SOC/2010/process/libs/process/example/wait_async_child.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/example/wait_async_child.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010)
+++ (empty file)
@@ -1,37 +0,0 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include <boost/process/all.hpp>
-#include <boost/asio.hpp>
-#include <iostream>
-
-using namespace boost::process;
-using namespace boost::asio;
-
-io_service ioservice;
-
-void end_wait(const boost::system::error_code &ec, int exit_code);
-
-int main()
-{
- std::string exe = find_executable_in_path("hostname");
- child c = create_child(exe);
- status s(ioservice);
- s.async_wait(c.get_id(), end_wait);
- ioservice.run();
-}
-
-void end_wait(const boost::system::error_code &ec, int exit_code)
-{
- if (!ec)
- std::cout << "exit code: " << exit_code << std::endl;
-}
Deleted: sandbox/SOC/2010/process/libs/process/example/wait_async_process.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/example/wait_async_process.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010)
+++ (empty file)
@@ -1,41 +0,0 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include <boost/process/all.hpp>
-#include <boost/asio.hpp>
-#include <boost/bind.hpp>
-#include <vector>
-#include <iterator>
-#include <iostream>
-
-using namespace boost::process;
-using namespace boost::asio;
-
-io_service ioservice;
-
-void end_wait(const boost::system::error_code &ec);
-
-int main()
-{
- std::vector<process> processes;
- create_snapshot(std::back_inserter(processes));
- process p = processes.front();
- status &s = p.status(ioservice);
- s.async_wait(boost::bind(&end_wait, placeholders::error));
- ioservice.run();
-}
-
-void end_wait(const boost::system::error_code &ec)
-{
- if (!ec)
- std::cout << "process exited" << std::endl;
-}
Deleted: sandbox/SOC/2010/process/libs/process/example/wait_child.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/example/wait_child.cpp 2010-07-31 12:59:13 \
EDT (Sat, 31 Jul 2010)
+++ (empty file)
@@ -1,25 +0,0 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include <boost/process/all.hpp>
-#include <string>
-#include <iostream>
-
-using namespace boost::process;
-
-int main()
-{
- std::string exe = find_executable_in_path("hostname");
- child c = create_child(exe);
- int exit_code = c.wait();
- std::cout << exit_code << std::endl;
-}
Deleted: sandbox/SOC/2010/process/libs/process/example/wait_process.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/example/wait_process.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010)
+++ (empty file)
@@ -1,28 +0,0 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include <boost/process/all.hpp>
-#include <vector>
-#include <iterator>
-#include <iostream>
-
-using namespace boost::process;
-
-int main()
-{
- std::vector<process> processes;
- create_snapshot(std::back_inserter(processes));
- process p = processes.front();
- status s = p.wait();
- if (s.exited())
- std::cout << s.exit_code() << std::endl;
-}
Deleted: sandbox/SOC/2010/process/libs/process/example/wait_sync_child.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/example/wait_sync_child.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010)
+++ (empty file)
@@ -1,26 +0,0 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include <boost/process/all.hpp>
-#include <string>
-#include <iostream>
-
-using namespace boost::process;
-
-int main()
-{
- std::string exe = find_executable_in_path("hostname");
- child c = create_child(exe);
- status s = c.wait();
- if (s.exited())
- std::cout << s.exit_code() << std::endl;
-}
Deleted: sandbox/SOC/2010/process/libs/process/example/write_async_to_child.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/example/write_async_to_child.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010)
+++ (empty file)
@@ -1,39 +0,0 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include <boost/asio.hpp>
-#include <boost/process/all.hpp>
-#include <boost/bind.hpp>
-#include <string>
-
-using namespace boost::process;
-using namespace boost::asio;
-
-io_service ioservice;
-
-void handler(const boost::system::error_code &ec, std::size_t bytes_transferred);
-
-int main()
-{
- std::string exe = find_executable_in_path("ftp");
- context ctx;
- ctx.stdin_behavior = \
behavior::named_pipe::def(behavior::named_pipe::input_stream);
- child c = create_child(exe, ctx);
- postream &os = c.get_stdin();
- pipe write_end(ioservice, os.native().release());
- async_write(write_end, buffer("quit\n"), handler);
- ioservice.run();
-}
-
-void handler(const boost::system::error_code &ec, std::size_t bytes_transferred)
-{
-}
Deleted: sandbox/SOC/2010/process/libs/process/example/write_async_to_parent.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/example/write_async_to_parent.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010)
+++ (empty file)
@@ -1,35 +0,0 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include <boost/all/process.hpp>
-#include <boost/asio.hpp>
-#include <boost/bind.hpp>
-
-using namespace boost::process;
-using namespace boost::asio;
-
-io_service ioservice;
-
-void end_write(const boost::system::error_code &ec);
-
-int main()
-{
- parent p;
- postream &os = p.get_stdin();
- pipe write_end(ioservice, os.native());
- async_write(write_end, buffer("Hello, world!"), boost::bind(&end_write, \
placeholders::error));
- ioservice.run();
-}
-
-void end_write(const boost::system::error_code &ec)
-{
-}
Deleted: sandbox/SOC/2010/process/libs/process/example/write_info_to_child.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/example/write_info_to_child.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010)
+++ (empty file)
@@ -1,30 +0,0 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include <boost/process/all.hpp>
-#include <boost/foreach.hpp>
-#include <vector>
-#include <iterator>
-#include <iostream>
-
-using namespace boost::process;
-
-int main()
-{
- std::vector<process> processes;
- options opts;
- opts.children_only = true;
- create_snapshot(std::back_inserter(processes), opts);
-
- BOOST_FOREACH(process &p, processes)
- p.set_priority(HIGH);
-}
Deleted: sandbox/SOC/2010/process/libs/process/example/write_info_to_self.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/example/write_info_to_self.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010)
+++ (empty file)
@@ -1,22 +0,0 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include <boost/process/all.hpp>
-#include <iostream>
-
-using namespace boost::process;
-
-int main()
-{
- self &s = self::get_instance();
- s.set_priority(HIGH);
-}
Deleted: sandbox/SOC/2010/process/libs/process/example/write_sync_to_child.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/example/write_sync_to_child.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010)
+++ (empty file)
@@ -1,27 +0,0 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include <boost/process/all.hpp>
-#include <string>
-#include <iostream>
-
-using namespace boost::process;
-
-int main()
-{
- std::string exe = find_executable_in_path("ftp");
- context ctx;
- ctx.stdin_behavior = behavior::pipe::def(behavior::pipe::input_stream);
- child c = create_child(exe, ctx);
- postream &os = c.get_stdin();
- os << "quit" << std::endl;
-}
Deleted: sandbox/SOC/2010/process/libs/process/example/write_to_child.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/example/write_to_child.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010)
+++ (empty file)
@@ -1,27 +0,0 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include <boost/all/process.hpp>
-#include <string>
-#include <iostream>
-
-using namespace boost::process;
-
-int main()
-{
- std::string exe = find_executable_in_path("ftp");
- context ctx;
- ctx.stdin_behavior = \
behavior::pipe::def(behavior::pipe::stream_type::input_stream);
- child c = create_child(exe, ctx);
- postream &os = c.get_stdin();
- os << "quit" << std::endl;
-}
Deleted: sandbox/SOC/2010/process/libs/process/example/write_to_parent.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/example/write_to_parent.cpp 2010-07-31 \
12:59:13 EDT (Sat, 31 Jul 2010)
+++ (empty file)
@@ -1,22 +0,0 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include <boost/all/process.hpp>
-
-using namespace boost::process;
-
-int main()
-{
- parent p;
- postream &os = p.get_stdin();
- os << "Hello, world!" << std::endl;
-}
Modified: sandbox/SOC/2010/process/libs/process/test/Jamfile.jam
==============================================================================
--- sandbox/SOC/2010/process/libs/process/test/Jamfile.jam (original)
+++ sandbox/SOC/2010/process/libs/process/test/Jamfile.jam 2010-07-31 12:59:13 EDT \
(Sat, 31 Jul 2010) @@ -15,8 +15,8 @@
explicit bfs ;
project : requirements
- <target-os>windows:<define>WIN32_LEAN_AND_MEAN
- <target-os>linux:<linkflags>-lpthread ;
+ <target-os>windows:<define>WIN32_LEAN_AND_MEAN
+ <target-os>linux:<linkflags>-lpthread ;
exe helpers : util/helpers.cpp bfs ;
explicit helpers ;
Modified: sandbox/SOC/2010/process/libs/process/test/arguments.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/test/arguments.cpp (original)
+++ sandbox/SOC/2010/process/libs/process/test/arguments.cpp 2010-07-31 12:59:13 EDT \
(Sat, 31 Jul 2010) @@ -37,7 +37,7 @@
args.push_back(word);
bp::context ctx;
- ctx.stdout_behavior = bpb::pipe::def(bpb::pipe::output_stream);
+ ctx.stdout_behavior = bpb::pipe::create(bpb::pipe::output_stream);
bp::child c = bp::create_child(get_helpers_path(), args, ctx);
bp::pistream &is = c.get_stdout();
Modified: sandbox/SOC/2010/process/libs/process/test/child.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/test/child.cpp (original)
+++ sandbox/SOC/2010/process/libs/process/test/child.cpp 2010-07-31 12:59:13 EDT \
(Sat, 31 Jul 2010) @@ -39,7 +39,7 @@
args.push_back("is-closed-stdin");
bp::context ctx;
- ctx.stdin_behavior = bpb::close::def();
+ ctx.stdin_behavior = bpb::close::create();
bp::child c = bp::create_child(get_helpers_path(), args, ctx);
@@ -60,7 +60,7 @@
args.push_back("is-closed-stdout");
bp::context ctx1;
- ctx1.stdout_behavior = bpb::close::def();
+ ctx1.stdout_behavior = bpb::close::create();
bp::child c1 = bp::create_child(get_helpers_path(), args, ctx1);
@@ -73,7 +73,7 @@
#endif
bp::context ctx2;
- ctx2.stdout_behavior = bpb::pipe::def(bpb::pipe::output_stream);
+ ctx2.stdout_behavior = bpb::pipe::create(bpb::pipe::output_stream);
bp::child c2 = bp::create_child(get_helpers_path(), args, ctx2);
@@ -94,7 +94,7 @@
args.push_back("is-closed-stderr");
bp::context ctx1;
- ctx1.stderr_behavior = bpb::close::def();
+ ctx1.stderr_behavior = bpb::close::create();
bp::child c1 = bp::create_child(get_helpers_path(), args, ctx1);
@@ -107,7 +107,7 @@
#endif
bp::context ctx2;
- ctx2.stderr_behavior = bpb::pipe::def(bpb::pipe::output_stream);
+ ctx2.stderr_behavior = bpb::pipe::create(bpb::pipe::output_stream);
bp::child c2 = bp::create_child(get_helpers_path(), args, ctx2);
@@ -128,8 +128,8 @@
args.push_back("stdin-to-stdout");
bp::context ctx;
- ctx.stdin_behavior = bpb::pipe::def(bpb::pipe::input_stream);
- ctx.stdout_behavior = bpb::pipe::def(bpb::pipe::output_stream);
+ ctx.stdin_behavior = bpb::pipe::create(bpb::pipe::input_stream);
+ ctx.stdout_behavior = bpb::pipe::create(bpb::pipe::output_stream);
bp::child c = bp::create_child(get_helpers_path(), args, ctx);
@@ -159,7 +159,7 @@
args.push_back("message-stdout");
bp::context ctx;
- ctx.stdout_behavior = bpb::pipe::def(bpb::pipe::output_stream);
+ ctx.stdout_behavior = bpb::pipe::create(bpb::pipe::output_stream);
bp::child c = bp::create_child(get_helpers_path(), args, ctx);
@@ -184,7 +184,7 @@
args.push_back("message-stderr");
bp::context ctx;
- ctx.stderr_behavior = bpb::pipe::def(bpb::pipe::output_stream);
+ ctx.stderr_behavior = bpb::pipe::create(bpb::pipe::output_stream);
bp::child c = bp::create_child(get_helpers_path(), args, ctx);
@@ -220,7 +220,7 @@
#endif
}
- static boost::shared_ptr<redirect_to> def(bp::handle stream_end)
+ static boost::shared_ptr<redirect_to> create(bp::handle stream_end)
{
return boost::make_shared<redirect_to>(redirect_to(stream_end));
}
@@ -241,8 +241,8 @@
args.push_back("message-to-two-streams");
bp::context ctx;
- ctx.stdout_behavior = bpb::pipe::def(bpb::pipe::output_stream);
- ctx.stderr_behavior = redirect_to::def(
+ ctx.stdout_behavior = bpb::pipe::create(bpb::pipe::output_stream);
+ ctx.stderr_behavior = redirect_to::create(
ctx.stdout_behavior->get_child_end());
bp::child c = bp::create_child(get_helpers_path(), args, ctx);
@@ -275,7 +275,7 @@
bp::context ctx;
BOOST_CHECK(bfs::equivalent(ctx.work_dir, bfs::current_path().string()));
- ctx.stdout_behavior = bpb::pipe::def(bpb::pipe::output_stream);
+ ctx.stdout_behavior = bpb::pipe::create(bpb::pipe::output_stream);
bp::child c = bp::create_child(get_helpers_path(), args, ctx);
@@ -309,7 +309,7 @@
{
bp::context ctx;
ctx.work_dir = wdir.string();
- ctx.stdout_behavior = bpb::pipe::def(bpb::pipe::output_stream);
+ ctx.stdout_behavior = bpb::pipe::create(bpb::pipe::output_stream);
bp::child c = bp::create_child(get_helpers_path(), args, ctx);
@@ -344,7 +344,7 @@
args.push_back("query-env");
args.push_back(var);
- ctx.stdout_behavior = bpb::pipe::def(bpb::pipe::output_stream);
+ ctx.stdout_behavior = bpb::pipe::create(bpb::pipe::output_stream);
bp::child c = bp::create_child(get_helpers_path(), args, ctx);
_______________________________________________
Boost-commit mailing list
Boost-commit@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-commit
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic