1
0
mirror of https://github.com/danog/process.git synced 2024-12-12 09:09:44 +01:00
process/example/watch-live.php
2017-03-16 10:04:52 -05:00

20 lines
441 B
PHP

<?php
include dirname(__DIR__) . "/vendor/autoload.php";
use Amp\Process\StreamedProcess;
Amp\Loop::run(function() {
$process = new StreamedProcess("echo 1; sleep 1; echo 2; sleep 1; echo 3; exit 42");
$promise = $process->execute();
$stdout = $process->getStdout();
while (yield $stdout->advance()) {
echo $stdout->getCurrent();
}
$code = yield $promise;
echo "Process exited with {$code}.\n";
});