doushi1473 2015-10-08 02:24
浏览 19

如何在页面浏览之间不断地与PHP中的后台进程通信?

Here is what I want to do: a PHP script(a.php) starts a background process from an executable(p1.exe written in other languages) which runs for several hours and produces a sequence of output, for example, 1,2,3... Subsequent page views of a.php get the output of p1 in order. Because the web server puts restricts on timeout of a PHP script, I have to access a.php repeatedly to read all the outputs of p1. For example, the second PV reads 1,2,3 and the third PV reads 4,5,6.

I tried popen to start a background process and read its output, witch worked well. But I don't know how to continue to read in next page views. I also found pcntl_fork(included in PCNTL extension) and thought I could start p1 in a child process witch continually reads p1 output and stores in $_SESSION for a.php(I'm not sure if this works). But the PCNTL extension is not available on Windows. Media, like via a file should work, but I'm looking for another way.

Any idea is appreciated.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 测距传感器数据手册i2c
    • ¥15 RPA正常跑,cmd输入cookies跑不出来
    • ¥15 求帮我调试一下freefem代码
    • ¥15 matlab代码解决,怎么运行
    • ¥15 R语言Rstudio突然无法启动
    • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
    • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
    • ¥15 用windows做服务的同志有吗
    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法