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
|
|
|
|
|
|
|
AsyncInterop\Loop::execute(\Amp\wrap(function() {
|
|
|
|
$process = new StreamedProcess('read ; echo "$REPLY"');
|
2017-01-15 16:30:34 +01:00
|
|
|
$promise = $process->execute();
|
2017-01-11 19:24:02 +01:00
|
|
|
|
|
|
|
/* send to stdin */
|
|
|
|
$process->write("abc\n");
|
|
|
|
|
2017-01-15 16:30:34 +01:00
|
|
|
echo yield $process->getStdout();
|
2017-01-11 19:24:02 +01:00
|
|
|
|
2017-01-15 16:30:34 +01:00
|
|
|
$code = yield $promise;
|
|
|
|
echo "Process exited with {$code}.\n";
|
2017-01-11 19:24:02 +01:00
|
|
|
}));
|