1
0
mirror of https://github.com/danog/process.git synced 2024-12-04 02:27:49 +01:00
process/example/watch-live.php

20 lines
456 B
PHP
Raw Normal View History

<?php
include dirname(__DIR__) . "/vendor/autoload.php";
2017-01-15 16:30:34 +01:00
use Amp\Process\StreamedProcess;
AsyncInterop\Loop::execute(\Amp\wrap(function() {
$process = new StreamedProcess("echo 1; sleep 1; echo 2; sleep 1; echo 3");
2017-01-15 16:30:34 +01:00
$promise = $process->execute();
2017-01-15 16:30:34 +01:00
$stdout = $process->getStdout();
2017-01-15 16:30:34 +01:00
while (yield $stdout->advance()) {
echo $stdout->getCurrent();
}
2017-01-15 16:30:34 +01:00
$code = yield $promise;
echo "Process exited with {$code}.\n";
}));