&2;sleep 1;echo error;sleep 1;nope'); $process->start($loop); $process->stdout->on('data', function ($chunk) { echo '(' . $chunk . ')'; }); $process->stderr->on('data', function ($chunk) { echo '[' . $chunk . ']'; }); $process->on('exit', function ($code) { echo 'EXIT with code ' . $code . PHP_EOL; }); $loop->run();