Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@webmozart
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webmozart/fa75d4c8d7ef0a4635a2 to your computer and use it in GitHub Desktop.
Save webmozart/fa75d4c8d7ef0a4635a2 to your computer and use it in GitHub Desktop.
<?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);
@pierrejoye
Copy link

Hm
Sure deadline reads from the proc open pipe? Afaics it does not. For one :)

@webmozart
Copy link
Author

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