如何与Apache使用pcntl_fork()? [英] how to use pcntl_fork() with Apache?

查看:552
本文介绍了如何与Apache使用pcntl_fork()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的code,在的index.php (只是一个例子):

This is my code, inside index.php (just an example):

$pid = pcntl_fork();
if ($pid == -1) {
  die("failed to fork");
} else if ($pid) {
  // nothing to do
} else {
  putDataIntoWebService();
  exit();
}
echo "normal page content";

本段工作在命令行罚款。在Apache的退出()杀他们两个,家长和孩子的过程。什么是一个解决办法?

This snippet works fine in command line. In Apache exit() kills them both, the parent and the kid process. What is a workaround?

推荐答案

这是解决方案:

posix_kill(getmypid(), SIGKILL);

而不是退出()

这篇关于如何与Apache使用pcntl_fork()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆