저는 Windows 7 및 PHP 5를 사용하고 있습니다.PHP stream_select doesnt work
proc_open으로 프로세스를 실행하고 시간 초과를 확인하는 데 문제가 있습니다.
<?php
$descriptorspec = array(
0 => array("file", $infile, "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("pipe", "w") // stderr is a file to write to
);
$prog = @proc_open ($objname.".exe", $descriptorspec, $pipes, "$DOCUMENT_ROOT/judge/temp", null, null);
if(!is_resource($prog)) ErrorResult("","proc_open err");
$streams = array($pipes[1]);
$start = microtime(true);
$ret = stream_select($streams, $a = null,$a = null, 1);
$stop = microtime(true);
?>
이 내가 그 테스트하는 데 사용되는 C++ 코드 : 가이 코드에 타임 아웃을 확인 stream_select를 사용하는 코드에서
#include<windows.h>
int main(){
Sleep(2000);
return 0;
}
이, 거기에 전혀 출력은 없지만 아무튼 stream_select 1 초를 기다렸다가 1을 반환합니다.
어떻게 해결할 수 있습니까?
'$ ret'와'$ streams'에는'stream_select'가 리턴 한 후에 무엇이 들어 있습니까? 'var_dump '를 제공하십시오. '$ ret'> 0이면'$ streams'은 비워 두어서는 안됩니다. '$ streams'이 비어 있지 않으면, 그 안에 들어있는 스트림을 읽을 때 무엇을 얻게됩니까? – Leigh
'$ pipes [1]'이 맞습니까? 당신은 단지 $ pipe [0]'이 2 개의 파이프만을 지정하고 있습니다. – Leigh
$ ret == 1이고 $ streams은 비어 있지 않습니다. 나는 아무것도 읽을 수 없다. –