时间:2021-07-01 10:21:17 帮助过:3人阅读
array("pipe", "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("file", "error-output.txt", "a") // stderr is a file to write to ); $process = proc_open("d:\\64test.exe", $descriptorspec, $pipes); if (is_resource($process)) { // $pipes now looks like this: // 0 => writeable handle connected to child stdin // 1 => readable handle connected to child stdout // Any error output will be appended to /tmp/error-output.txt fwrite($pipes[0], "q"); fclose($pipes[0]); while (!feof($pipes[1])) { $result = fgets($pipes[1], 1024); echo "r:$result
"; } fclose($pipes[1]); // It is important that you close any pipes before calling // proc_close in order to avoid a deadlock $return_value = proc_close ($process); echo "command returned $return_value
"; } ?>
#includeusing namespace std; int main(int argc,char *argv[]) { char buf[1024]={0}; /*fgets(buf,sizeof(buf),stdin);*/ while(buf[0]!='q') { std::cin>>buf; std::cout<