PHP uses the process as the daemon.
This example describes how PHP uses a process as a daemon. Share it with you for your reference. The specific analysis is as follows:
Usage of posix_setsid () in php
The document explains "Make the current process a session leader"
Reference: http://linux.die.net/man/2/setsid
This means that the process that calls this function between a process group (parent process and child process) will be elected as the leader of the Process Group.
So the way to make a process a daemon is:
1 fork generates a sub-process
2 In the sub-process posix_setsid ()
3. Exit the parent process.
This document provides an example:
<? 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 <= 60; $ I ++) {// do something for 5 minutes sleep (5) ;}}?>
I hope this article will help you with php programming.