Swoole Server Linux Process Manager addProcess

public boolean Swoole\Server::addProcess ( Swoole\Process $process )
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.

$server = new Swoole\Server('', 9501);

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


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