Latest version: pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5


OpenSwoole Process can be attached and managed by OpenSwoole Server with addProcess API.

OpenSwoole Process can be used to replace PHP pcntl extension. Compare with PHP pcntl, OpenSwoole Process provides more features:

  • IPC based on unixsock, with read/write or push/pop API.
  • Redirect standard I\O
  • The child processes are able to use OpenSwoole\Event.
  • Exec API allows the child process execute native Linux command and communicate with the parent process

You can use Process Pool or Process Manager if you like to manage a group of daemon processes and not attaching to an OpenSwoole Server.



$process = new OpenSwoole\Process(function($worker){
    echo "the pid of child process is " . $worker->pid . "\n";
    echo "the file descriptor of pipe is " . $worker->pipe . "\n";

    $res = $worker->write("Hello main process\n");
    var_dump(strlen("Hello main process\n"));

    $worker->name("php child process");
}, FALSE);



echo $process->read();
Last updated on February 8, 2023