start(); /* send to stdin */ $process->write("abc\n"); $listener = new Listener($process->getStdOut()); while (yield $listener->advance()) { echo $listener->getCurrent(); } echo "Process exited with {$listener->getResult()}.\n"; }));