WAMP和pcntl_fork

时间:2011-02-02 19:43:06

标签: php wamp

有没有办法让pcntl_fork在WAMP中工作?我需要开发一个分叉解决方案并在本地进行测试。

3 个答案:

答案 0 :(得分:10)

不,这是不可能的。 PCNTL扩展名需要* nix平台。

现在,有了这个说,你想做什么,你可以解决它吗?

修改:启动后台流程的其他选择:

答案 1 :(得分:-1)

伪代码解决方案:

while (TRUE)
{
   $process_limit = get_process_limit();
   $process_count = get_process_count();

   if process count < process limit:
   {
      // get_row returns a row (as an array) from the DB that needs to be processed
      $row = get_row();
      if($row === array())
      {
         // Nothing to process; sleep
         sleep(2);
      }
      else
      {
         // Process row
         process_count(+1);
         process_row($row);
         process_count(-1);
      }

   }
   elseif process count === process limit
   {
      // Do not add to the process
      exit;
   }
   elseif process count > process limit
   {
      // Means the process limit was decreased
      // Terminate this process instance
      process_count(-1);
      exit;
   }
}

答案 2 :(得分:-1)

这已经得到了回答,但我想我会加上我的2p。

你可以使用cygwin在windows中使用php进行pcntl-fork。

安装真的很痛苦,但如果像我一样你只想运行一个php cli脚本,这是你最好的选择。

我收到了来自here的说明: