1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Does Boost.Log support process forking?</title> 5<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../index.html" title="Chapter 1. Boost.Log v2"> 8<link rel="up" href="../rationale.html" title="Rationale and FAQ"> 9<link rel="prev" href="why_not_log4j.html" title="Why not using hierarchy of loggers, like in log4j? Why not Boost.Log4j? Etc."> 10<link rel="next" href="init_term_support.html" title="Does Boost.Log support logging at process initialization and termination?"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td></tr></table> 14<hr> 15<div class="spirit-nav"> 16<a accesskey="p" href="why_not_log4j.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../rationale.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="init_term_support.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 17</div> 18<div class="section"> 19<div class="titlepage"><div><div><h3 class="title"> 20<a name="log.rationale.fork_support"></a><a class="link" href="fork_support.html" title="Does Boost.Log support process forking?">Does Boost.Log support process 21 forking?</a> 22</h3></div></div></div> 23<p> 24 No, currently Boost.Log does not support process forking (i.e. <code class="computeroutput"><span class="identifier">fork</span></code> call in UNIX systems). There are several 25 issues with process forking, for instance: 26 </p> 27<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 28<li class="listitem"> 29 File sinks do not attempt to reopen log files or synchronize access to 30 files between parent and child processes. The resulting output may be 31 garbled. 32 </li> 33<li class="listitem"> 34 File collectors do not expect several processes attempting to collect 35 log files to the same target directory. This may result in spurious failures 36 at log file rotation. 37 </li> 38<li class="listitem"> 39 The <a class="link" href="../detailed/attributes.html#log.detailed.attributes.process_id" title="Current process identifier">current_process_id</a> 40 attribute value will not update in the child process. 41 </li> 42<li class="listitem"> 43 In multithreaded applications, one can generally not guarantee that a 44 thread is not executing some Boost.Log code while an other thread forks. 45 Some Boost.Log resources may be left irreversibly locked or broken in 46 the forked process. This reservation is not specific to Boost.Log, other 47 libraries and even the application itself are susceptible to this problem. 48 </li> 49</ul></div> 50<p> 51 There may be other issues as well. It seems unlikely that support for forking 52 will be added to Boost.Log any time soon. 53 </p> 54<div class="note"><table border="0" summary="Note"> 55<tr> 56<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td> 57<th align="left">Note</th> 58</tr> 59<tr><td align="left" valign="top"><p> 60 This does not preclude the <code class="computeroutput"><span class="identifier">fork</span></code>+<code class="computeroutput"><span class="identifier">exec</span></code> sequence from working. As long as 61 the forked process doesn't try to use any of Boost.Log code, the process 62 should be able to call <code class="computeroutput"><span class="identifier">exec</span></code> 63 or a similar function to load and start another executable. 64 </p></td></tr> 65</table></div> 66</div> 67<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 68<td align="left"></td> 69<td align="right"><div class="copyright-footer">Copyright © 2007-2019 Andrey Semashev<p> 70 Distributed under the Boost Software License, Version 1.0. (See accompanying 71 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>). 72 </p> 73</div></td> 74</tr></table> 75<hr> 76<div class="spirit-nav"> 77<a accesskey="p" href="why_not_log4j.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../rationale.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="init_term_support.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 78</div> 79</body> 80</html> 81