<?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 => 'it',
  ),
  'this' => 
  array (
    0 => 'function.pcntl-rfork.php',
    1 => 'pcntl_rfork',
    2 => 'Manipulates process resources',
  ),
  'up' => 
  array (
    0 => 'ref.pcntl.php',
    1 => 'PCNTL Funzioni',
  ),
  'prev' => 
  array (
    0 => 'function.pcntl-getqos-class.php',
    1 => 'pcntl_getqos_class',
  ),
  'next' => 
  array (
    0 => 'function.pcntl-setcpuaffinity.php',
    1 => 'pcntl_setcpuaffinity',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/pcntl/functions/pcntl-rfork.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.pcntl-rfork" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">pcntl_rfork</h1>
  <p class="verinfo">(PHP 8 &gt;= 8.1.0)</p><p class="refpurpose"><span class="refname">pcntl_rfork</span> &mdash; <span class="dc-title">Manipulates process resources</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.pcntl-rfork-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>pcntl_rfork</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$flags</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$signal</code><span class="initializer"> = 0</span></span>): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

  <p class="para rdfs-comment">
   Manipulates process resources.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.pcntl-rfork-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">flags</code></dt>
     <dd>
      <p class="para">
       The <code class="parameter">flags</code> parameter determines which resources of the invoking process (parent)
       are shared by the new process (child) or initialized to their default values.
      </p>
      <p class="para">
       <code class="parameter">flags</code> is the logical OR of some subset of:
       <ul class="simplelist">
        <li>
         <strong><code><a href="pcntl.constants.php#constant.rfproc">RFPROC</a></code></strong>: If set a new process is created;
         otherwise changes affect the current process.
        </li>
        <li>
         <strong><code><a href="pcntl.constants.php#constant.rfnowait">RFNOWAIT</a></code></strong>: If set, the child process will be dissociated from the parent.
         Upon exit the child will not leave a status for the parent to collect.
        </li>
        <li>
         <strong><code><a href="pcntl.constants.php#constant.rffdg">RFFDG</a></code></strong>: If set, the invoker's file descriptor table is copied;
         otherwise the two processes share a single table.
        </li>
        <li>
         <strong><code><a href="pcntl.constants.php#constant.rfcfdg">RFCFDG</a></code></strong>: If set, the new process starts with a clean file descriptor table.
         Is mutually exclusive with <strong><code><a href="pcntl.constants.php#constant.rffdg">RFFDG</a></code></strong>.
        </li>
        <li>
         <strong><code><a href="pcntl.constants.php#constant.rflinuxthpn">RFLINUXTHPN</a></code></strong>: If set, the kernel will return SIGUSR1 instead of SIGCHILD upon thread exit for the child.
         This is intended to do Linux clone exit parent notification.
        </li>
       </ul>
      </p>
     </dd>
    
    
     <dt><code class="parameter">signal</code></dt>
     <dd>
      <p class="para">
       The signal number.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.pcntl-rfork-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">
   On success, the PID of the child process is returned in the
   parent&#039;s thread of execution, and a <code class="literal">0</code> is returned in the child&#039;s
   thread of execution. 
   On failure, a <code class="literal">-1</code> 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-rfork-examples">
  <h3 class="title">Esempi</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>pcntl_rfork()</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_rfork</span><span style="color: #007700">(</span><span style="color: #0000BB">RFNOWAIT</span><span style="color: #007700">|</span><span style="color: #0000BB">RFTSIGZMB</span><span style="color: #007700">, </span><span style="color: #0000BB">SIGUSR1</span><span style="color: #007700">);<br />if (</span><span style="color: #0000BB">$pid </span><span style="color: #007700">&gt; </span><span style="color: #0000BB">0</span><span style="color: #007700">) {<br />  </span><span style="color: #FF8000">// This is the parent process.<br />  </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$pid</span><span style="color: #007700">);<br />} else {<br />  </span><span style="color: #FF8000">// This is the child process.<br />  </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$pid</span><span style="color: #007700">);<br />  </span><span style="color: #0000BB">sleep</span><span style="color: #007700">(</span><span style="color: #0000BB">2</span><span style="color: #007700">); </span><span style="color: #FF8000">// as the child does not wait, so we see its "pid"<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Il precedente esempio visualizzerà
qualcosa simile a:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">int(77093)
int(0)</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.pcntl-rfork-notes">
  <h3 class="title">Note</h3>
  <blockquote class="note"><p><strong class="note">Nota</strong>: 
   <p class="para">
    This function is only available on BSD systems.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.pcntl-rfork-seealso">
  <h3 class="title">Vedere anche:</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.pcntl-fork.php" class="function" rel="rdfs-seeAlso">pcntl_fork()</a> - Forks the currently running process</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); ?>