1
0
mirror of https://github.com/danog/process.git synced 2024-12-11 16:49:40 +01:00
process/examples/watch-live.php

19 lines
411 B
PHP
Raw Normal View History

<?php
include dirname(__DIR__) . "/vendor/autoload.php";
use Amp\Process\Process;
2017-06-15 19:11:38 +02:00
Amp\Loop::run(function () {
$process = new Process("echo 1; sleep 1; echo 2; sleep 1; echo 3; exit 42");
2017-06-15 19:02:50 +02:00
$process->start();
$stream = $process->getStdout();
while ($chunk = yield $stream->read()) {
2017-06-15 19:02:50 +02:00
echo $chunk;
}
2017-06-15 19:02:50 +02:00
$code = yield $process->join();
2017-01-15 16:30:34 +01:00
echo "Process exited with {$code}.\n";
});