<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.pcntl.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.pcntl-fork.php',
    1 => 'pcntl_fork',
    2 => 'Forks the currently running process',
  ),
  'up' => 
  array (
    0 => 'ref.pcntl.php',
    1 => 'Функції PCNTL',
  ),
  'prev' => 
  array (
    0 => 'function.pcntl-exec.php',
    1 => 'pcntl_exec',
  ),
  'next' => 
  array (
    0 => 'function.pcntl-get-last-error.php',
    1 => 'pcntl_get_last_error',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/pcntl/functions/pcntl-fork.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.pcntl-fork" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">pcntl_fork</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.1.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">pcntl_fork</span> &mdash; <span class="dc-title">Forks the currently running process</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.pcntl-fork-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>pcntl_fork</strong></span>(): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

  <p class="para rdfs-comment">
   The <span class="function"><strong>pcntl_fork()</strong></span> function creates a child
   process that differs from the parent process only in its PID and
   PPID. Please see your system&#039;s fork(2) man page for specific details as to
   how fork works on your system.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.pcntl-fork-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">У цієї функції немає
параметрів.</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.pcntl-fork-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   On success, the PID of the child process is returned in the
   parent&#039;s thread of execution, and a 0 is returned in the child&#039;s
   thread of execution.  On failure, a -1 will be returned in the
   parent&#039;s context, no child process will be created, and a PHP
   error is raised.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.pcntl-fork-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 <span class="function"><strong>pcntl_fork()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$pid </span><span style="color: #007700">= </span><span style="color: #0000BB">pcntl_fork</span><span style="color: #007700">();<br />if (</span><span style="color: #0000BB">$pid </span><span style="color: #007700">== -</span><span style="color: #0000BB">1</span><span style="color: #007700">) {<br />     die(</span><span style="color: #DD0000">'could not fork'</span><span style="color: #007700">);<br />} else if (</span><span style="color: #0000BB">$pid</span><span style="color: #007700">) {<br />     </span><span style="color: #FF8000">// we are the parent<br />     </span><span style="color: #0000BB">pcntl_wait</span><span style="color: #007700">(</span><span style="color: #0000BB">$status</span><span style="color: #007700">); </span><span style="color: #FF8000">//Protect against Zombie children<br /></span><span style="color: #007700">} else {<br />     </span><span style="color: #FF8000">// we are the child<br /></span><span style="color: #007700">}<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.pcntl-fork-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.pcntl-rfork.php" class="function" rel="rdfs-seeAlso">pcntl_rfork()</a> - Manipulates process resources</span></li>
    <li><span class="function"><a href="function.pcntl-waitpid.php" class="function" rel="rdfs-seeAlso">pcntl_waitpid()</a> - Waits on or returns the status of a forked child</span></li>
    <li><span class="function"><a href="function.pcntl-signal.php" class="function" rel="rdfs-seeAlso">pcntl_signal()</a> - Installs a signal handler</span></li>
    <li><span class="function"><a href="function.cli-set-process-title.php" class="function" rel="rdfs-seeAlso">cli_set_process_title()</a> - Sets the process title</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>