Next

Chapter 1. Boost.Process

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)

Table of Contents

Introduction
Tutorial
Header files
Namespaces
Starting a program
Cleaning up resources
Handling errors
Setting command line arguments
Starting in a specific work directory
Inheriting environment variables
Setting up standard streams
Synchronous I/O
Asynchronous I/O
Waiting for a program to exit
Terminating a program
Windows specifics
Setting wShowWindow
Unicode
Arbitrary extensions
POSIX specifics
Binding file descriptors
Closing file descriptors
Arbitrary extensions
FAQ
Why does the parent process hang if a pipe is used to redirect a child's output stream?
Why can executing /bin/ls make a parent process seem to hang?
Is Boost.Process thread-safe?
Reference
Header <boost/process.hpp>
Header <boost/process/child.hpp>
Header <boost/process/config.hpp>
Header <boost/process/create_pipe.hpp>
Header <boost/process/execute.hpp>
Header <boost/process/executor.hpp>
Header <boost/process/initializers.hpp>
Header <boost/process/mitigate.hpp>
Header <boost/process/pipe.hpp>
Header <boost/process/search_path.hpp>
Header <boost/process/shell_path.hpp>
Header <boost/process/terminate.hpp>
Header <boost/process/wait_for_exit.hpp>
Acknowledgements

Boost.Process is a library to manage system processes. It can be used to:

  • create child processes
  • setup streams for child processes
  • communicate with child processes through streams (synchronously or asynchronously)
  • wait for processes to exit (synchronously or asynchronously)
  • terminate processes

Here's a simple example of how to start a program with Boost.Process:

#include <boost/process.hpp>

using namespace boost::process;
using namespace boost::process::initializers;

int main()
{
    execute(run_exe("test.exe"));
}

[Caution] Caution

This is not yet an official Boost C++ library. It wasn't reviewed and can't be downloaded from www.boost.org. It is however the latest version of an ongoing effort to create a process management library for Boost. For now the library can be downloaded from http://www.highscore.de/boost/process0.5/process.zip.

Last revised: December 08, 2012 at 18:30:14 GMT


Next