Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Chapter 29. Boost.Process

Klemens David Morgenstern

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
Concepts
Pipes
Processes
Environment
Tutorial
Starting a process
Launch functions
Error
Synchronous I/O
Asynchronous I/O
Groups
Environment
Design Rationale
Scope
Interface Style
Arguments/Command Style
Extensions
Extensions
Structure
Simple extensions
Handler Types
Asynchronous Functionality
Error handling
Executor Overloading
Frequently Asked Questions
Why does this produce a deadlock?
Why does the pipe not close?
When will the codecvt be used?
Reference
Header <boost/process/args.hpp>
Header <boost/process/async.hpp>
Header <boost/process/async_pipe.hpp>
Header <boost/process/async_system.hpp>
Header <boost/process/child.hpp>
Header <boost/process/cmd.hpp>
Header <boost/process/env.hpp>
Header <boost/process/environment.hpp>
Header <boost/process/error.hpp>
Header <boost/process/exception.hpp>
Header <boost/process/exe.hpp>
Header <boost/process/extend.hpp>
Header <boost/process/group.hpp>
Header <boost/process/io.hpp>
Header <boost/process/locale.hpp>
Header <boost/process/pipe.hpp>
Header <boost/process/posix.hpp>
Header <boost/process/search_path.hpp>
Header <boost/process/shell.hpp>
Header <boost/process/spawn.hpp>
Header <boost/process/start_dir.hpp>
Header <boost/process/system.hpp>
Header <boost/process/windows.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;

int main()
{
    ipstream pipe_stream;
    child c("gcc --version", std_out > pipe_stream);

    std::string line;

    while (pipe_stream && std::getline(pipe_stream, line) && !line.empty())
        std::cerr << line << std::endl;

    c.wait();
}

Last revised: August 01, 2018 at 21:06:21 GMT


PrevUpHomeNext