We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$pid = pcntl_fork(); if( $pid > 0 ){ // 下面这个函数可以更改php进程的名称 cli_set_process_title('php father process'); // 返回值保存在$wait_result中 // $pid参数表示 子进程的进程ID // 子进程状态则保存在了参数$status中 // 将第三个option参数设置为常量WNOHANG,则可以避免主进程阻塞挂起,此处父进程将立即返回继续往下执行剩下的代码 $wait_result = pcntl_waitpid( $pid, $status, WNOHANG ); var_dump( $wait_result ); var_dump( $status ); echo "不阻塞,运行到这里".PHP_EOL; // 让主进程休息60秒钟 sleep(60); } else if( 0 == $pid ) { cli_set_process_title('php child process'); // 让子进程休息10秒钟,但是进程结束后,父进程不对子进程做任何处理工作,这样这个子进程就会变成僵尸进程 sleep(10); } else { exit('fork error.'.PHP_EOL); }
我运行试了这段代码,没有成为僵尸进程,是怎么回事。
The text was updated successfully, but these errors were encountered:
了解到你是使用win10内置的bash shell,这种情况并未测试过,你可以在纯Linux下再试一下。
问题不关闭了,给其他遇到这个问题的人看。
Sorry, something went wrong.
感谢作者 从您的文章里学到了很多 所有例子清晰透明 通俗易懂 期待您其他的文章!
No branches or pull requests
我运行试了这段代码,没有成为僵尸进程,是怎么回事。
The text was updated successfully, but these errors were encountered: