2015-04-22 16:44:54 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Amp\Process;
|
|
|
|
|
|
|
|
include __DIR__."/../vendor/autoload.php";
|
|
|
|
|
|
|
|
\Amp\run(function() {
|
2015-09-16 19:56:15 +02:00
|
|
|
$proc = new Process("echo 1; sleep 1; echo 2; sleep 1; echo 3");
|
|
|
|
$promise = $proc->exec();
|
2015-04-22 16:44:54 +02:00
|
|
|
|
2015-09-16 19:56:15 +02:00
|
|
|
$promise->watch(function($data) {
|
|
|
|
// $data[0] is either "out" or "err", $data[1] the actual data
|
|
|
|
list($type, $msg) = $data;
|
|
|
|
// "1" ... 2 seconds ... "2" ... 2 seconds ... "3"
|
|
|
|
print "$type: $msg";
|
|
|
|
});
|
2015-04-22 16:44:54 +02:00
|
|
|
|
2015-09-16 19:56:15 +02:00
|
|
|
$result = (yield $promise);
|
2015-04-22 16:44:54 +02:00
|
|
|
|
2015-09-16 19:56:15 +02:00
|
|
|
// we aren't buffering by default (Process::BUFFER_NONE is default) ... so only exit code present and eventually the killing signal
|
|
|
|
var_dump($result);
|
|
|
|
});
|