Imported Upstream version 1.64.0
[platform/upstream/boost.git] / doc / html / process.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
5 <title>Chapter&#160;29.&#160;Boost.Process</title>
6 <link rel="stylesheet" href="../../doc/src/boostbook.css" type="text/css">
7 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
8 <link rel="home" href="index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
9 <link rel="up" href="libraries.html" title="Part&#160;I.&#160;The Boost C++ Libraries (BoostBook Subset)">
10 <link rel="prev" href="predef/acknoledgements.html" title="Acknoledgements">
11 <link rel="next" href="boost_process/concepts.html" title="Concepts">
12 </head>
13 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
14 <table cellpadding="2" width="100%"><tr>
15 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../boost.png"></td>
16 <td align="center"><a href="../../index.html">Home</a></td>
17 <td align="center"><a href="../../libs/libraries.htm">Libraries</a></td>
18 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
19 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
20 <td align="center"><a href="../../more/index.htm">More</a></td>
21 </tr></table>
22 <hr>
23 <div class="spirit-nav">
24 <a accesskey="p" href="predef/acknoledgements.html"><img src="../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="libraries.html"><img src="../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost_process/concepts.html"><img src="../../doc/src/images/next.png" alt="Next"></a>
25 </div>
26 <div class="chapter">
27 <div class="titlepage"><div>
28 <div><h2 class="title">
29 <a name="process"></a>Chapter&#160;29.&#160;Boost.Process</h2></div>
30 <div><div class="author"><h3 class="author">
31 <span class="firstname">Klemens David</span> <span class="surname">Morgenstern</span>
32 </h3></div></div>
33 <div><p class="copyright">Copyright &#169; 2006-2012 Julio M. Merino Vidal, Ilya Sokolov,
34       Felipe Tanus, Jeff Flinn, Boris Schaeling</p></div>
35 <div><p class="copyright">Copyright &#169; 2016 Klemens D. Morgenstern</p></div>
36 <div><div class="legalnotice">
37 <a name="process.legal"></a><p>
38         Distributed under the Boost Software License, Version 1.0. (See accompanying
39         file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
40       </p>
41 </div></div>
42 </div></div>
43 <div class="toc">
44 <p><b>Table of Contents</b></p>
45 <dl class="toc">
46 <dt><span class="section"><a href="process.html#boost_process.introduction">Introduction</a></span></dt>
47 <dt><span class="section"><a href="boost_process/concepts.html">Concepts</a></span></dt>
48 <dd><dl>
49 <dt><span class="section"><a href="boost_process/concepts.html#boost_process.concepts.pipes">Pipes</a></span></dt>
50 <dt><span class="section"><a href="boost_process/concepts.html#boost_process.concepts.process">Processes</a></span></dt>
51 <dt><span class="section"><a href="boost_process/concepts.html#boost_process.concepts.env">Environment</a></span></dt>
52 </dl></dd>
53 <dt><span class="section"><a href="boost_process/tutorial.html">Tutorial</a></span></dt>
54 <dd><dl>
55 <dt><span class="section"><a href="boost_process/tutorial.html#boost_process.tutorial.starting_a_process">Starting a
56       process</a></span></dt>
57 <dt><span class="section"><a href="boost_process/tutorial.html#boost_process.tutorial.launch_mode">Launch functions</a></span></dt>
58 <dt><span class="section"><a href="boost_process/tutorial.html#boost_process.tutorial.error_handling">Error</a></span></dt>
59 <dt><span class="section"><a href="boost_process/tutorial.html#boost_process.tutorial.io">Synchronous I/O</a></span></dt>
60 <dt><span class="section"><a href="boost_process/tutorial.html#boost_process.tutorial.async_io">Asynchronous I/O</a></span></dt>
61 <dt><span class="section"><a href="boost_process/tutorial.html#boost_process.tutorial.group">Groups</a></span></dt>
62 <dt><span class="section"><a href="boost_process/tutorial.html#boost_process.tutorial.env">Environment</a></span></dt>
63 </dl></dd>
64 <dt><span class="section"><a href="boost_process/design.html">Design Rationale</a></span></dt>
65 <dd><dl>
66 <dt><span class="section"><a href="boost_process/design.html#boost_process.design.scope">Scope</a></span></dt>
67 <dt><span class="section"><a href="boost_process/design.html#boost_process.design.interface_style">Interface Style</a></span></dt>
68 <dt><span class="section"><a href="boost_process/design.html#boost_process.design.arg_cmd_style">Arguments/Command
69       Style</a></span></dt>
70 <dt><span class="section"><a href="boost_process/design.html#boost_process.design.plat_ext">Extensions</a></span></dt>
71 </dl></dd>
72 <dt><span class="section"><a href="boost_process/extend.html">Extensions</a></span></dt>
73 <dd><dl>
74 <dt><span class="section"><a href="boost_process/extend.html#boost_process.extend.structure">Structure</a></span></dt>
75 <dt><span class="section"><a href="boost_process/extend.html#boost_process.extend.simple">Simple extensions</a></span></dt>
76 <dt><span class="section"><a href="boost_process/extend.html#boost_process.extend.handler">Handler Types</a></span></dt>
77 <dt><span class="section"><a href="boost_process/extend.html#boost_process.extend.async">Asynchronous Functionality</a></span></dt>
78 <dt><span class="section"><a href="boost_process/extend.html#boost_process.extend.error">Error handling</a></span></dt>
79 <dt><span class="section"><a href="boost_process/extend.html#boost_process.extend.exec_over">Executor Overloading</a></span></dt>
80 </dl></dd>
81 <dt><span class="section"><a href="boost_process/faq.html">Frequently Asked Questions</a></span></dt>
82 <dd><dl>
83 <dt><span class="section"><a href="boost_process/faq.html#boost_process.faq.dead_lock">Why does this produce a
84       deadlock?</a></span></dt>
85 <dt><span class="section"><a href="boost_process/faq.html#boost_process.faq.closep">Why does the pipe not close?</a></span></dt>
86 <dt><span class="section"><a href="boost_process/faq.html#boost_process.faq.wchar_t">When will the codecvt be used?</a></span></dt>
87 </dl></dd>
88 <dt><span class="section"><a href="process/reference.html">Reference</a></span></dt>
89 <dd><dl>
90 <dt><span class="section"><a href="process/reference.html#header.boost.process.args_hpp">Header &lt;boost/process/args.hpp&gt;</a></span></dt>
91 <dt><span class="section"><a href="process/reference.html#header.boost.process.async_hpp">Header &lt;boost/process/async.hpp&gt;</a></span></dt>
92 <dt><span class="section"><a href="process/reference.html#header.boost.process.async_pipe_hpp">Header &lt;boost/process/async_pipe.hpp&gt;</a></span></dt>
93 <dt><span class="section"><a href="process/reference.html#header.boost.process.async_system_hpp">Header &lt;boost/process/async_system.hpp&gt;</a></span></dt>
94 <dt><span class="section"><a href="process/reference.html#header.boost.process.child_hpp">Header &lt;boost/process/child.hpp&gt;</a></span></dt>
95 <dt><span class="section"><a href="process/reference.html#header.boost.process.cmd_hpp">Header &lt;boost/process/cmd.hpp&gt;</a></span></dt>
96 <dt><span class="section"><a href="process/reference.html#header.boost.process.env_hpp">Header &lt;boost/process/env.hpp&gt;</a></span></dt>
97 <dt><span class="section"><a href="process/reference.html#header.boost.process.environment_hpp">Header &lt;boost/process/environment.hpp&gt;</a></span></dt>
98 <dt><span class="section"><a href="process/reference.html#header.boost.process.error_hpp">Header &lt;boost/process/error.hpp&gt;</a></span></dt>
99 <dt><span class="section"><a href="process/reference.html#header.boost.process.exception_hpp">Header &lt;boost/process/exception.hpp&gt;</a></span></dt>
100 <dt><span class="section"><a href="process/reference.html#header.boost.process.exe_hpp">Header &lt;boost/process/exe.hpp&gt;</a></span></dt>
101 <dt><span class="section"><a href="process/reference.html#header.boost.process.extend_hpp">Header &lt;boost/process/extend.hpp&gt;</a></span></dt>
102 <dt><span class="section"><a href="process/reference.html#header.boost.process.group_hpp">Header &lt;boost/process/group.hpp&gt;</a></span></dt>
103 <dt><span class="section"><a href="process/reference.html#header.boost.process.io_hpp">Header &lt;boost/process/io.hpp&gt;</a></span></dt>
104 <dt><span class="section"><a href="process/reference.html#header.boost.process.locale_hpp">Header &lt;boost/process/locale.hpp&gt;</a></span></dt>
105 <dt><span class="section"><a href="process/reference.html#header.boost.process.pipe_hpp">Header &lt;boost/process/pipe.hpp&gt;</a></span></dt>
106 <dt><span class="section"><a href="process/reference.html#header.boost.process.posix_hpp">Header &lt;boost/process/posix.hpp&gt;</a></span></dt>
107 <dt><span class="section"><a href="process/reference.html#header.boost.process.search_path_hpp">Header &lt;boost/process/search_path.hpp&gt;</a></span></dt>
108 <dt><span class="section"><a href="process/reference.html#header.boost.process.shell_hpp">Header &lt;boost/process/shell.hpp&gt;</a></span></dt>
109 <dt><span class="section"><a href="process/reference.html#header.boost.process.spawn_hpp">Header &lt;boost/process/spawn.hpp&gt;</a></span></dt>
110 <dt><span class="section"><a href="process/reference.html#header.boost.process.start_dir_hpp">Header &lt;boost/process/start_dir.hpp&gt;</a></span></dt>
111 <dt><span class="section"><a href="process/reference.html#header.boost.process.system_hpp">Header &lt;boost/process/system.hpp&gt;</a></span></dt>
112 <dt><span class="section"><a href="process/reference.html#header.boost.process.windows_hpp">Header &lt;boost/process/windows.hpp&gt;</a></span></dt>
113 </dl></dd>
114 <dt><span class="section"><a href="boost_process/acknowledgements.html">Acknowledgements</a></span></dt>
115 </dl>
116 </div>
117 <div class="section">
118 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
119 <a name="boost_process.introduction"></a><a class="link" href="process.html#boost_process.introduction" title="Introduction">Introduction</a>
120 </h2></div></div></div>
121 <p>
122       Boost.Process is a library to manage system processes. It can be used to:
123     </p>
124 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
125 <li class="listitem">
126           create child processes
127         </li>
128 <li class="listitem">
129           setup streams for child processes
130         </li>
131 <li class="listitem">
132           communicate with child processes through streams (synchronously or asynchronously)
133         </li>
134 <li class="listitem">
135           wait for processes to exit (synchronously or asynchronously)
136         </li>
137 <li class="listitem">
138           terminate processes
139         </li>
140 </ul></div>
141 <p>
142       Here's a simple example of how to start a program with Boost.Process:
143     </p>
144 <p>
145 </p>
146 <pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><code class="computeroutput">boost/process.hpp</code><span class="special">&gt;</span>
147
148 <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">process</span><span class="special">;</span>
149
150 <span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
151 <span class="special">{</span>
152     <code class="computeroutput"><a class="link" href="process/reference.html#boost.process.ipstream">ipstream</a></code> <span class="identifier">pipe_stream</span><span class="special">;</span>
153     <code class="computeroutput">child</code> <span class="identifier">c</span><span class="special">(</span><span class="string">"gcc --version"</span><span class="special">,</span> <code class="computeroutput"><a class="link" href="boost/process/std_out.html" title="Global std_out">std_out</a></code> <span class="special">&gt;</span> <span class="identifier">pipe_stream</span><span class="special">);</span>
154
155     <a href="http://en.cppreference.com/w/cpp/string/basic_string" target="_top">std::string</a> <span class="identifier">line</span><span class="special">;</span>
156
157     <span class="keyword">while</span> <span class="special">(</span><span class="identifier">pipe_stream</span> <span class="special">&amp;&amp;</span> <a href="http://en.cppreference.com/w/cpp/string/basic_string/getline" target="_top">std::getline</a><span class="special">(</span><span class="identifier">pipe_stream</span><span class="special">,</span> <span class="identifier">line</span><span class="special">)</span> <span class="special">&amp;&amp;</span> <span class="special">!</span><span class="identifier">line</span><span class="special">.</span><span class="identifier">empty</span><span class="special">())</span>
158         <span class="identifier">std</span><span class="special">::</span><span class="identifier">cerr</span> <span class="special">&lt;&lt;</span> <span class="identifier">line</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
159
160     <span class="identifier">c</span><span class="special">.</span><span class="identifier">wait</span><span class="special">();</span>
161 <span class="special">}</span>
162 </pre>
163 <p>
164     </p>
165 </div>
166 </div>
167 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
168 <td align="left"><p><small>Last revised: April 17, 2017 at 02:30:54 GMT</small></p></td>
169 <td align="right"><div class="copyright-footer"></div></td>
170 </tr></table>
171 <hr>
172 <div class="spirit-nav">
173 <a accesskey="p" href="predef/acknoledgements.html"><img src="../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="libraries.html"><img src="../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost_process/concepts.html"><img src="../../doc/src/images/next.png" alt="Next"></a>
174 </div>
175 </body>
176 </html>