跨持久连接弹出句柄 [英] popen handle across persistent connections

查看:71
本文介绍了跨持久连接弹出句柄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用popen执行命令,然后通过AJAX打印出其进度.我发现此帖子非常有用,并且使AJAX脚本交换可以正常工作.问题在于,每次从ajax到test都有一个异步GET时,都会重复popen上的句柄.如果我的外壳程序只运行一次,则该句柄不再有效.我不知道如何使$ handle成为持久的跨请求.

I am trying to execute a command by using popen and then print out its progress via AJAX. I have found this post extremely helpful and got the AJAX to script exchange working fine. The problem is that every time there is an async GET to test from ajax, the handle on popen is repeated. If I have the shell only run once, then the handle is no longer valid. I can't figure out how to make $handle be persistent accross requests.

public function test()
{
      chdir('my dir');
      $handle = popen('make install 2>&1','r');
      echo fread($handle, 2096);


}

一次只能有一个用户请求此请求....仅用于后台管理. AJAX的输出始终为在src中安装".

There will only be one user requesting this at a time....only used on the Admin back end of things. The output from AJAX is always, "Making install in src".

推荐答案

您不能这样做.您必须在后台运行"make install"过程(例如,通过exec()),并将其输出重定向到执行AJAX请求时可以读取的文件/管道.

You can't do that. You'll have to run the 'make install' process in the background (e.g. via exec()) and redirect it's output to a file/pipe that you can read from when executing the AJAX requests.

这篇关于跨持久连接弹出句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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