: This article mainly introduces PHPDaemon development-using QPM to manage PID files. For more information about PHP tutorials, see. When writing a Daemon program, we can use a PID file to mark whether the process has been created to prevent the process from being started repeatedly. The PID file also records the process number to send signals to the process. Pidfile in QPM is the module used to manage PID files.
Example:
# Pid_main.php Start (); while (true) sleep (10);?> Run php pid_main.php for the first time. we can see that the pid_main.php.pid file is generated, and the process continues to run. Run php pid_main.php again, and the script reports an error, prompting that the process already exists. Fatal error: Uncaught exception 'qpm \ pidfile \ exception' with message' process exists, no need to start a new one 'in.../qpm/pidfile/Manager. php: 41
In addition, qpm \ pid \ Manager has the getProcess method.
# Pid_check.php GetProcess ()-> getPid ();?> If the pid file does not exist or is empty, an exception is thrown. Note: the object obtained by The getProcess method is not 100% the original process. The detection here will be improved in later versions.
The above introduces PHP Daemon development-using QPM to manage PID files, including some content, and hope to be helpful to friends who are interested in PHP tutorials.