Codebase list php-react-child-process / a02d7a95-53be-4032-a4df-48d88e9c9990/main examples / 22-race-exit.php
a02d7a95-53be-4032-a4df-48d88e9c9990/main

Tree @a02d7a95-53be-4032-a4df-48d88e9c9990/main (Download .tar.gz)

22-race-exit.php @a02d7a95-53be-4032-a4df-48d88e9c9990/mainraw · history · blame

<?php

use React\EventLoop\Factory;
use React\ChildProcess\Process;

require __DIR__ . '/../vendor/autoload.php';

$loop = Factory::create();

$first = new Process('php -r "sleep(2);"', null, null, array());
$first->start($loop);

$first->on('exit', function ($code) {
    echo 'First closed ' . $code . PHP_EOL;
});

$second = new Process('php -r "sleep(1);"', null, null, array());
$second->start($loop);

$second->on('exit', function ($code) {
    echo 'Second closed ' . $code . PHP_EOL;
});

$loop->run();