Composer
I want you to act as a composer. I will provide the lyrics to a song and you will create music for it. This could include using various instruments or tools, such as synthesizers or samplers, in order...
向进程发送信号
Sign in to like and favorite skills
I want you to act as a composer. I will provide the lyrics to a song and you will create music for it. This could include using various instruments or tools, such as synthesizers or samplers, in order...
I want you to act as a philosopher. I will provide some topics or questions related to the study of philosophy, and it will be your job to explore these concepts in depth. This could involve conductin...
I want you to act as a personal trainer. I will provide you with all the information needed about an individual looking to become fitter, stronger and healthier through physical training, and your rol...
向进程发送信号
int swoole_process::kill($pid, $signo = SIGTERM);
此方法类似于posix_kill http://php.net/manual/zh/function.posix-kill.php
子进程退出后,父进程务必要执行swoole_process::wait进行回收,否则这个子进程就会变为僵尸进程。会浪费操作系统的进程资源。
父进程可以设置监听SIGCHLD信号,收到信号后执行swoole_process::wait回收退出的子进程。
<?php $process = new swoole_process('callback_function', true); //子进程执行的逻辑 function callback_function(swoole_process $worker) { swoole_timer_tick(2000,function(){ echo time(); }) } $pid = $process->start(); //父进程执行的逻辑 //监听子进程退出信号 swoole_process::signal(SIGCHLD, function($sig) { //必须为false,非阻塞模式 while($ret = swoole_process::wait(false)) { //执行回收后的处理逻辑,比如拉起一个新的进程 } });