即使system()中的命令完成,PHP system()也会挂起
I have a code something like this:
我有一个像这样的代码:
$file = fopen( "debug.txt", "w" );
$command = "myExe.exe param0 param1";
fprintf( $file, "starting\r\n" );
fflush( $file );
system( $command );
fprintf( $file, "the end...\r\n" );
fflush( $file );
It prints "starting" but not "the end...". The system() function hangs.
它打印“开始”但不打印“结束......”。 system()函数挂起。
The myExe.exe is an applicatication written in C++, which actually terminates; i.e. the main function of myExe ends with a code like this:
myExe.exe是一个用C ++编写的应用程序,它实际上终止了;即myExe的主要功能以这样的代码结束:
FILE* f = fopen( "test.txt", "w" );
fclose(f);
return 0;
test.txt is created, which means "myExe.exe" works and finishes normally.
创建test.txt,这意味着“myExe.exe”正常工作并完成。
That problem does not occur each time we call the php file; sometimes hangs, sometimes works...
每次调用php文件时都不会出现这个问题;有时挂起,有时候工作......
Any help&idea will be appriciated. Thanks in advance.
任何帮助和想法都会得到满足。提前致谢。
info; OS: win xp php server: wamp server 2.0
信息; OS:win xp php server:wamp server 2.0
edit: my problem is not about my debug files. It is about system() or exec() functions. I can remove all other lines.
编辑:我的问题与我的调试文件无关。它是关于system()或exec()函数。我可以删除所有其他行。
my php script works well for about 4/5 tries. After system() called, i call some sql functions but when system() hangs, my page will give a fatal error.
我的PHP脚本适用于大约4/5次尝试。在调用system()后,我调用了一些sql函数,但是当system()挂起时,我的页面会发出致命的错误。
4 个解决方案
#1
1
There is a known bug in php on windows (http://bugs.php.net/bug.php?id=44942).
There is a workaround you may want to try, close the session (call session_write_close() ) before calling the exec function.
Windows上的php中存在一个已知错误(http://bugs.php.net/bug.php?id=44942)。您可能需要尝试一种解决方法,在调用exec函数之前关闭会话(调用session_write_close())。
更多相关文章
- [开心学php100天]第五天:string函数(上)
- curl获取网页内容出现乱码或为空的解决方案,另附curl_getinfo函数
- APMServ 在 Win7 下出现“APMServ-Apache 服务因 函数不正确。
- 本机PHP函数将授予我直接访问字符串部分而无需创建临时数组的权
- 从。net调用Magento API,并得到“位于XYZ的HTTP服务太忙”的错误
- 我得到了“致命错误:未捕获的SoapFault异常:[客户机]SoapClient:
- php的冷门函数之——call_user_func_array,func_get_args,func_n
- PHP 源码 —— is_array 函数源码分析
- php中的date函数中时区问题