pcntl_exec() 函数的工作方式与标准(unix 风格)exec() 函数完全相同。它与常规 PHP exec() 函数的不同之处在于,调用 pcntl_exec() 的进程被替换为被调用的进程。这是创建孩子的理想方法
。在一个简单的例子中(不进行错误检查):
switch (pcntl_fork()) {
case 0:
$cmd = "/path/to/command";
$args = array("arg1", "arg2");
pcntl_exec($cmd, $args);
// the child will only reach this point on exec failure,
// because execution shifts to the pcntl_exec()ed command
exit(0);
default:
break;
}
// parent continues
echo "I am the parent";
Run Code Online (Sandbox Code Playgroud)
从这里的评论引用: https ://www.php.net/manual/en/function.pcntl-exec.php
| 归档时间: |
|
| 查看次数: |
4282 次 |
| 最近记录: |