创建 test.php
<?php
$worker_num = 2;
for($i=0; $i<$worker_num; $i++){sleep(1);$process = new swoole_process(function(swoole_process $worker){var_dump($worker);//查看进程的情况});$pid = $process->start();echo "pid = {$pid}".PHP_EOL;
}
执行脚本
php test.php
$ php test.php
object(Swoole\Process)#1 (6) {["pipe"]=>int(4)["callback"]=>NULL["msgQueueId"]=>NULL["msgQueueKey"]=>NULL["pid"]=>int(287)["id"]=>NULL
}
object(Swoole\Process)#3 (6) {["pipe"]=>int(6)["callback"]=>NULL["msgQueueId"]=>NULL["msgQueueKey"]=>NULL["pid"]=>int(288)["id"]=>NULL
}
属性
pipe
进程的管道IDpid
当前子进程的PIDcallback
回调函数名称