Swoole Server Linux Process Manager addProcess

public boolean Swoole\Server::addProcess ( Swoole\Process $process )
<?php
bool Swoole\Server->addProcess(Swoole\Process $process)

Attach a user defined Linux process Swoole Process to Swoole Server. The process will be managed by Swoole Server and also can access the status of Swoole Server or communicate with it.

It is useful to expose the function of a Linux process to a web service.

Example:
<?php
$server = new Swoole\Server('127.0.0.1', 9501);

$process = new Swoole\Process(function($process) use ($server) {
    while (true) {
        $msg = $process->read();
        foreach($server->connections as $conn) {
            $server->send($conn, $msg);
        }
    }
});

$server->addProcess($process);

$server->on('receive', function ($serv, $fd, $from_id, $data) use ($process) {
    // send the data received to all the child processes
    $process->write($data);
});

$server->start();