mirror of
https://github.com/danog/process.git
synced 2024-11-27 04:35:02 +01:00
18 lines
391 B
PHP
18 lines
391 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");
|
|
$process->start();
|
|
|
|
while ($chunk = yield $process->read()) {
|
|
echo $chunk;
|
|
}
|
|
|
|
$code = yield $process->join();
|
|
echo "Process exited with {$code}.\n";
|
|
});
|