• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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=UTF-8">
5<title>Concepts</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="../process.html" title="Chapter 29. Boost.Process">
10<link rel="prev" href="../process.html" title="Chapter 29. Boost.Process">
11<link rel="next" href="tutorial.html" title="Tutorial">
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="../process.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../process.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="tutorial.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
25</div>
26<div class="section">
27<div class="titlepage"><div><div><h2 class="title" style="clear: both">
28<a name="boost_process.concepts"></a><a class="link" href="concepts.html" title="Concepts">Concepts</a>
29</h2></div></div></div>
30<div class="toc"><dl class="toc">
31<dt><span class="section"><a href="concepts.html#boost_process.concepts.pipes">Pipes</a></span></dt>
32<dt><span class="section"><a href="concepts.html#boost_process.concepts.process">Processes</a></span></dt>
33<dt><span class="section"><a href="concepts.html#boost_process.concepts.env">Environment</a></span></dt>
34</dl></div>
35<p>
36      In this section, some of the underlying concepts of the operating system used
37      in this library, will be explained. In the following chapters we will presume
38      knowledge of that. Though please note, that this is a short summary and not
39      conclusive of everything that can be done.
40    </p>
41<p>
42      The goal of this library is to implement a portable wrapper, so that we will
43      explain mostly what windows and posix have in common.
44    </p>
45<div class="section">
46<div class="titlepage"><div><div><h3 class="title">
47<a name="boost_process.concepts.pipes"></a><a class="link" href="concepts.html#boost_process.concepts.pipes" title="Pipes">Pipes</a>
48</h3></div></div></div>
49<div class="toc"><dl class="toc">
50<dt><span class="section"><a href="concepts.html#boost_process.concepts.pipes.anonymous">Anonymous Pipes</a></span></dt>
51<dt><span class="section"><a href="concepts.html#boost_process.concepts.pipes.named">Named Pipes</a></span></dt>
52</dl></div>
53<p>
54        Pipes are a facility for communication between different threads, processes
55        and in some cases machines, the operating system provides.
56      </p>
57<p>
58        The typical feature of a pipe is, that it is one channel, to which two handles
59        are given, one for reading (source), one for writing (sink). In that it is
60        different than other facilities (like sockets) and provides another way to
61        manage the connectivity: if one side of the pipe is closed (i.e. the pipe
62        is broken), the other is notified.
63      </p>
64<p>
65        Pipes are typically used for interprocess communication. The main reason
66        is, that pipes can be directly assigned to the process stdio, i.e. stderr,
67        stdin and stdout. Additionally, half of the pipe can be inherited to the
68        child process and closed in the father process. This will cause the pipe
69        to be broken when the child process exits.
70      </p>
71<p>
72        Though please note, that if the same thread reads and writes to a pipe, it
73        will only talk to itself.
74      </p>
75<div class="section">
76<div class="titlepage"><div><div><h4 class="title">
77<a name="boost_process.concepts.pipes.anonymous"></a><a class="link" href="concepts.html#boost_process.concepts.pipes.anonymous" title="Anonymous Pipes">Anonymous Pipes</a>
78</h4></div></div></div>
79<p>
80          The most common pipes are anonymous. Since they have no name, a handle
81          to them can only be obtained from duplicating either handle.
82        </p>
83<p>
84          In this library the following functions are used for the creation of unnamed
85          pipes:
86        </p>
87<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
88<li class="listitem">
89              <a href="http://pubs.opengroup.org/onlinepubs/7908799/xsh/pipe.html" target="_top">posix</a>
90            </li>
91<li class="listitem">
92              <a href="https://msdn.microsoft.com/de-de/library/windows/desktop/aa365152.aspx" target="_top">windows</a>
93            </li>
94</ul></div>
95</div>
96<div class="section">
97<div class="titlepage"><div><div><h4 class="title">
98<a name="boost_process.concepts.pipes.named"></a><a class="link" href="concepts.html#boost_process.concepts.pipes.named" title="Named Pipes">Named Pipes</a>
99</h4></div></div></div>
100<p>
101          As the name suggests, named pipes have a string identifier. This means
102          that a handle to them can be obtained with the identifier, too.
103        </p>
104<p>
105          The implementation on posix uses <a href="(http://pubs.opengroup.org/onlinepubs/009695399/functions/mkfifo.html" target="_top">fifos</a>,
106          which means, that the named pipe behaves like a file.
107        </p>
108<p>
109          Windows does provide a facility called <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa365150(v=vs.85).aspx" target="_top">named
110          pipes</a>, which also have file-like names, but are in a different
111          scope than the actual file system.
112        </p>
113<div class="note"><table border="0" summary="Note">
114<tr>
115<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/src/images/note.png"></td>
116<th align="left">Note</th>
117</tr>
118<tr><td align="left" valign="top"><p>
119            The main reason named pipes are part of this library, is because they
120            need to be internally used for asynchrounous communication on windows.
121          </p></td></tr>
122</table></div>
123</div>
124</div>
125<div class="section">
126<div class="titlepage"><div><div><h3 class="title">
127<a name="boost_process.concepts.process"></a><a class="link" href="concepts.html#boost_process.concepts.process" title="Processes">Processes</a>
128</h3></div></div></div>
129<div class="toc"><dl class="toc">
130<dt><span class="section"><a href="concepts.html#boost_process.concepts.process.exit_code">Exit code</a></span></dt>
131<dt><span class="section"><a href="concepts.html#boost_process.concepts.process.termination">Termination</a></span></dt>
132</dl></div>
133<p>
134        A process is an independently executable entity, which is different from
135        a thread, in that it has its own resources. Those include memory and hardware
136        resources.
137      </p>
138<p>
139        Every process is identified by a unique number<a href="#ftn.boost_process.concepts.process.f0" class="footnote" name="boost_process.concepts.process.f0"><sup class="footnote">[28]</sup></a>, called the process identification digit, <code class="computeroutput"><span class="identifier">pid</span></code>.
140      </p>
141<div class="section">
142<div class="titlepage"><div><div><h4 class="title">
143<a name="boost_process.concepts.process.exit_code"></a><a class="link" href="concepts.html#boost_process.concepts.process.exit_code" title="Exit code">Exit code</a>
144</h4></div></div></div>
145<p>
146          A process will return an integer value indicating whether it was successful.
147          On posix there are more codes associated with that, but not so on windows.
148          Therefore there is no such encoding currently in the library. However an
149          exit code of zero means the process was successful, while one different
150          than zero indicates an error.
151        </p>
152</div>
153<div class="section">
154<div class="titlepage"><div><div><h4 class="title">
155<a name="boost_process.concepts.process.termination"></a><a class="link" href="concepts.html#boost_process.concepts.process.termination" title="Termination">Termination</a>
156</h4></div></div></div>
157<p>
158          Processes can also be forced to exit. There are two ways to do this, signal
159          the process to do so and wait, and just terminate the process without conditions.
160        </p>
161<p>
162          Usually the first approach is to signal an exit request, but windows -
163          unlike posix - does not provide a consistent way to do this. Hence this
164          is not part of the library and only the hard terminate is.
165        </p>
166</div>
167</div>
168<div class="section">
169<div class="titlepage"><div><div><h3 class="title">
170<a name="boost_process.concepts.env"></a><a class="link" href="concepts.html#boost_process.concepts.env" title="Environment">Environment</a>
171</h3></div></div></div>
172<p>
173        The environment is a map of variables local to every process. The most significant
174        one for this library is the <code class="computeroutput"><span class="identifier">PATH</span></code>
175        variable, which contains a list of paths, that ought to be searched for executables.
176        A shell will do this automatically, while this library provides a function
177        for that.
178      </p>
179</div>
180<div class="footnotes">
181<br><hr style="width:100; text-align:left;margin-left: 0">
182<div id="ftn.boost_process.concepts.process.f0" class="footnote"><p><a href="#boost_process.concepts.process.f0" class="para"><sup class="para">[28] </sup></a>
183          it is unique as long as the process is active
184        </p></div>
185</div>
186</div>
187<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
188<td align="left"></td>
189<td align="right"><div class="copyright-footer">Copyright © 2006-2012 Julio M. Merino Vidal, Ilya Sokolov,
190      Felipe Tanus, Jeff Flinn, Boris Schaeling<br>Copyright © 2016 Klemens D. Morgenstern<p>
191        Distributed under the Boost Software License, Version 1.0. (See accompanying
192        file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
193      </p>
194</div></td>
195</tr></table>
196<hr>
197<div class="spirit-nav">
198<a accesskey="p" href="../process.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../process.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="tutorial.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
199</div>
200</body>
201</html>
202