<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.exec.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.proc-get-status.php',
    1 => 'proc_get_status',
    2 => '获取由 proc_open 函数打开的进程的信息',
  ),
  'up' => 
  array (
    0 => 'ref.exec.php',
    1 => '程序执行函数',
  ),
  'prev' => 
  array (
    0 => 'function.proc-close.php',
    1 => 'proc_close',
  ),
  'next' => 
  array (
    0 => 'function.proc-nice.php',
    1 => 'proc_nice',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/exec/functions/proc-get-status.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.proc-get-status" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">proc_get_status</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">proc_get_status</span> &mdash; <span class="dc-title">获取由 <span class="function"><a href="function.proc-open.php" class="function">proc_open()</a></span> 函数打开的进程的信息</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.proc-get-status-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>proc_get_status</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$process</code></span>): <span class="type"><a href="language.types.array.php" class="type array">array</a></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>proc_get_status()</strong></span> 函数可以获取由
   <span class="function"><a href="function.proc-open.php" class="function">proc_open()</a></span> 函数打开的进程的信息。
  </p>
 </div>

 
 <div class="refsect1 parameters" id="refsect1-function.proc-get-status-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">process</code></dt>
     <dd>
      <p class="para">
       要检查的由 <span class="function"><a href="function.proc-open.php" class="function">proc_open()</a></span> 打开的进程 <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.proc-get-status-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   收集了进程信息的 <span class="type"><a href="language.types.array.php" class="type array">array</a></span>。返回的数组包含下列元素：
  </p>
  <p class="para">
  <table class="doctable informaltable">
   
    <thead>
     <tr><th>元素</th><th>类型</th><th>描述</th></tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>command</td>
      <td><span class="type"><a href="language.types.string.php" class="type string">string</a></span></td>
      <td>
       传入 <span class="function"><a href="function.proc-open.php" class="function">proc_open()</a></span> 函数的命令行字符串。
      </td>
     </tr>

     <tr>
      <td>pid</td>
      <td><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></td>
      <td>进程 ID</td>
     </tr>

     <tr>
      <td>running</td>
      <td><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></td>
      <td>
       <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> 表示进程还在运行中， <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> 表示进程已经终止
      </td>
     </tr>

     <tr>
      <td>signaled</td>
      <td><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></td>
      <td>
       <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> 表示子进程被未捕获的信号所终止。
       在 Windows 平台永远为 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。
      </td>
     </tr>

     <tr>
      <td>stopped</td>
      <td><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></td>
      <td>
        <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> 表示子进程被信号停止。
        在 Windows 平台永远为 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。
      </td>
     </tr>

     <tr>
      <td>exitcode</td>
      <td><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></td>
      <td>
        进程的退出码（仅在 <code class="literal">running</code> 为 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> 时有意义）。PHP
        8.3.0 之前，此函数仅第一次调用返回实际的值，后续调用均返回 <code class="literal">-1</code>。
      </td>
     </tr>

     <tr>
      <td>cached</td>
      <td><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></td>
      <td>
       自 PHP 8.3.0 起，当 exit 代码已缓存时为 <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>。缓存是必要的，确保 exit 代码不会在后续调用进程 API 时丢失。
      </td>
     </tr>

     <tr>
      <td>termsig</td>
      <td><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></td>
      <td>
        导致子进程终止执行的信号值
        （仅在 <code class="literal">signaled</code> 为 <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> 时有意义）。
      </td>
     </tr>

     <tr>
      <td>stopsig</td>
      <td><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></td>
      <td>
        导致子进程停止执行的信号值
        （仅在 <code class="literal">stopped</code> 为 <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> 时有意义）。
      </td>
     </tr>

    </tbody>
   
  </table>

  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.proc-get-status-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.3.0</td>
      <td>
       返回的数组中添加了<code class="literal">&quot;cached&quot;</code> 条目。PHP 8.3.0 之前，只有第一次调用才会返回真正的
       exit 代码。<code class="literal">&quot;cached&quot;</code> 条目表示已缓存 exit 代码。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 seealso" id="refsect1-function.proc-get-status-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.proc-open.php" class="function" rel="rdfs-seeAlso">proc_open()</a> - 执行一个命令，并且打开用来输入/输出的文件指针。</span></li>
   </ul>
  </p>
 </div>

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