2017-01-11 19:24:02 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
include dirname(__DIR__) . "/vendor/autoload.php";
|
|
|
|
|
2017-01-15 16:30:34 +01:00
|
|
|
use Amp\Process\StreamedProcess;
|
2017-01-11 19:24:02 +01:00
|
|
|
|
2017-06-15 19:11:38 +02:00
|
|
|
Amp\Loop::run(function () {
|
2017-03-16 16:04:52 +01:00
|
|
|
$process = new StreamedProcess("echo 1; sleep 1; echo 2; sleep 1; echo 3; exit 42");
|
2017-06-15 19:02:50 +02:00
|
|
|
$process->start();
|
2017-01-11 19:24:02 +01:00
|
|
|
|
2017-06-15 19:02:50 +02:00
|
|
|
while ($chunk = yield $process->read()) {
|
|
|
|
echo $chunk;
|
2017-01-11 19:24:02 +01:00
|
|
|
}
|
|
|
|
|
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";
|
2017-03-16 16:04:52 +01:00
|
|
|
});
|