3 if($argc < 2) die("usage: pwrap command\n");
4 for($i=1;$i<$argc;$i++
) $command = $command.' '.$argv[$i];
6 $descriptorspec = array(
7 0 => array("pipe", "r"), // stdout
8 1 => array("pipe", "w"), // stdin
9 //2 => array("pipe", "r") // stderr
10 //2 => array("file", "./error-output.txt", "a") // stderr is a file to write to
15 $process = proc_open($command, $descriptorspec, $pipes, $cwd, $_ENV);
16 $stdin = fopen('php://stdin', 'r');
18 stream_set_blocking($pipes[0], 0);
19 stream_set_blocking($pipes[1], 0);
20 //stream_set_blocking($pipes[2], 0);
21 stream_set_blocking($stdin, 0);
23 while(!feof($pipes[0]) && !feof($pipes[1])) {
24 echo(fgetc($pipes[1]));
25 fwrite($pipes[0], fgetc($stdin));
This page took 0.304979 seconds and 4 git commands to generate.