Last active
August 29, 2015 14:11
-
-
Save webmozart/fa75d4c8d7ef0a4635a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$dspec = array( | |
0 => STDIN, | |
1 => STDOUT, | |
2 => STDERR, | |
); | |
$tempfile = tempnam(sys_get_temp_dir(), 'lesstest'); | |
file_put_contents($tempfile, <<<EOF | |
Some text | |
to be | |
displayed with | |
less. | |
EOF | |
); | |
// run the external command | |
$proc = proc_open('less '.$tempfile, $dspec, $pipes, null, null); | |
if (is_resource($proc)) { | |
while (true) { | |
$stat = proc_get_status($proc); | |
if ($stat['running']) { | |
break; | |
} | |
sleep(1); | |
} | |
} | |
proc_close($proc); |
I got it! Updated the Gist. Thanks :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hm
Sure deadline reads from the proc open pipe? Afaics it does not. For one :)