The swoole process child process fatal, the parent process can not listen to the SIGCHLD signal?

Use process multiprocess in

cli mode. The
master process exits and restarts the child process through the SIGCHLD listening child process.


    swoole_process::signal(SIGCHLD, function(){
        // 
        while ($ret = swoole_process::wait(false)) {
            unset(self::$wokers[$ret["pid"]]);
            self::logError("SIGNAL-WORKER_EXIT-%s", $ret["pid"]);
            //
            self::initProcess();
        }
    });

directly kill the child process, and the parent process can receive the signal and pull the child process again.

when fatal occurs in the child process, the parent process does not receive the signal that the child process exits, and the child process becomes a zombie process.

[php] <defunct>

would like to ask all the bosses have encountered this kind of situation? When pcntl is implemented, when the child process fatal, the parent process is subject to SIGCHLD.

Jun.26,2022

the main reason for this situation may be that there is a problem with your parent process logic. swoole_process::signal is asynchronous signal processing, and your program is completely asynchronous and non-blocking. If your parent process code is while (true) endless loop, synchronous blocking, there is no chance to execute it.

Menu