public function testShellTimeout()
 {
     $shell = new Shell();
     $shell->setProcessLimit(1);
     $command1 = sprintf('%s -r %s', $this->phpExecutablePath, escapeshellarg('echo "Hello world!";'));
     $command2 = sprintf('%s -r %s', $this->phpExecutablePath, escapeshellarg('sleep(5);' . 'echo "Hello world!";'));
     $process1 = $shell->startProcess($command1);
     $process2 = $shell->startProcess($command2);
     try {
         $shell->wait(0.5);
         $this->fail('The expected exception was not thrown');
     } catch (TimeoutException $e) {
     }
     $this->assertSame(FutureProcess::STATUS_EXITED, $process1->getStatus(false));
     $this->assertSame('Hello world!', $process1->readFromPipe(1));
     $this->assertSame(FutureProcess::STATUS_RUNNING, $process2->getStatus(false));
     $process2->abort();
 }
<?php

require_once __DIR__ . '/../vendor/autoload.php';
use FutureProcess\Shell;
use FutureProcess\FutureProcess;
use FutureProcess\FutureResult;
$shell = new Shell();
$url = 'https://raw.githubusercontent.com/joshdifabio/future-process/master/LICENSE';
$process = $shell->startProcess("wget -O - {$url}");
// this will not block, even if the process is queued
$process->then(function (FutureProcess $process) {
    echo "Downloading file...\n";
});
// this will not block, even if the process is queued
$process->getResult()->then(function (FutureResult $result) {
    echo "File contents:\n{$result->readFromPipe(1)}\n";
});
// this will block until all processes have exited
$shell->wait();