pcntl_exec 和 php 中的 exec 有什么区别?
what is the difference between pcntl_exec and exec in php?
我已经阅读了 http://us1.php.net/manual/en/function.pcntl-exec.php and http://php.net/manual/en/function.exec.php 上的文档,但我无法真正说出实际区别是什么。
The pcntl_exec() function works exactly like the standard (unix-style)
exec() function. It differs from the regular PHP exec() function in
that the process calling the pcntl_exec() is replaced with the process
that gets called. This is the ideal method for creating children
。在一个简单的示例中(不进行错误检查):
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";
引用自此处的评论:
http://us1.php.net/manual/en/function.pcntl-exec.php
我已经阅读了 http://us1.php.net/manual/en/function.pcntl-exec.php and http://php.net/manual/en/function.exec.php 上的文档,但我无法真正说出实际区别是什么。
The pcntl_exec() function works exactly like the standard (unix-style) exec() function. It differs from the regular PHP exec() function in that the process calling the pcntl_exec() is replaced with the process that gets called. This is the ideal method for creating children
。在一个简单的示例中(不进行错误检查):
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";
引用自此处的评论: http://us1.php.net/manual/en/function.pcntl-exec.php