I'm using Windows 7 and php 5.
I have a problem with executing a process by proc_open and check the timeout. I used stream_select to check the timeout with this code:
<?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);
?>
This is the C++ code I used to test that:
#include<windows.h>
int main(){
Sleep(2000);
return 0;
}
In that code, there's no output at all, but stream_select doesn't wait 1 sec and return 1.
How can i fix this?