* @license http://www.zend.com/license/3_0.txt PHP License 3.0
* @version 1.0.0
*/
/** 确保这个函数只能运行在SHELL中 */
if (substr(php_sapi_name(), 0, 3) !== 'cli') {
die("This Programe can only be run in CLI mode");
}
/** 关闭最大执行时间限制, 在CLI模式下, 这个语句其实不必要 */
set_time_limit(0);
$pid = posix_getpid(); //取得主进程ID
$user = posix_getlogin(); //取得用户名
echo
但有一点, 我一定要提醒:
[U]复制代码[/U] 代码如下:
Process Control should not be enabled within a webserver environment and unexpected results may happen if any Process Control functions are used within a webserver environment. --摘自PHP手也就是说, 打消你在PHP Web开发中使用多进程的念头吧!