PHP processes the process as a daemon, the PHP process daemon
The example in this article describes how PHP processes the process as a daemon. Share to everyone for your reference. The specific analysis is as follows:
Usage of posix_setsid () in PHP
Document interpretation is "make the current process a session leader"
Reference Document: Http://linux.die.net/man/2/setsid
The process that calls this function between a process group (parent and child processes) is elected as a leader of the process group
So the way to make a process a daemon is to:
1 Fork out a sub-process
2 in child process Posix_setsid ()
3 Exiting the parent process
There is an example in the documentation:
<?php $pid = Pcntl_fork ();//Fork if ($pid < 0) exit; else if ($pid)//parent exit; else {//child $sid = Posix_setsid (); if ($sid < 0) exit; for ($i = 0; $i <=, $i + +) {//do something for 5 minutes sleep (5); } }? >
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/970856.html www.bkjia.com true http://www.bkjia.com/PHPjc/970856.html techarticle PHP processes the process as a daemon, and the PHP process daemon describes how PHP processes the process as a daemon. Share to everyone for your reference. The specific analysis is as follows: ...