easyphp
<?php
//题目环境:php:7.4.8-apache
$pid = pcntl_fork(); //创建一个子进程
//子进程和父进程都会执行以下代码
if ($pid == -1) { //错误处理,创建失败返回-1
die('could not fork');
}else if ($pid){
//父进程会获得子进程号,所以这里是父进程执行逻辑
$r=pcntl_wait($status); //等待子进程中断,防止子进程成为僵尸进程
if(!pcntl_wifexited($status)){ //挂起当前进行进程直到一个子进程退出或者收到一个信号要求中断当前进程或调用一个信号处理进程。
phpinfo();
}
}else if ($pid == 0){ //子进程pid为0,这里是子进程逻辑
highlight_file(__FILE__);
if(isset($_GET['a'])&&is_string($_GET['a'])&&!preg_match("/[:\\\\]|exec|pcntl/i",$_GET['a'])){
call_user_func_array($_GET['a'],[$_GET['b'],false,true]);
call_user_func_array(call(pcntl_wait()))
}
posix_kill(posix_getpid(), SIGUSR1);
}Last updated