search
HomeBackend DevelopmentPHP ProblemHow php manages processes

How php manages processes

Sep 20, 2019 pm 01:15 PM
php

How php manages processes

Process Management-Preventing Processes from Becoming Zombie Processes

After the process is created, how do you manage the child processes?

Using signals to manage child processes, there are generally two situations: (Recommended learning: PHP programming from entry to proficiency)

posix_kill() : This function does not, as the name suggests, operate the child process by sending a signal to the child process. When necessary, you can choose to send a process termination signal to the child process to terminate the child process;

pcntl_waitpid(): Wait for or return the child process status of fork. If the specified child process has exited when this function is called (commonly known as a zombie process), this function will return immediately and release all system resources of the child process. This The process can prevent the child process from becoming a zombie process, causing a waste of system resources;

Orphan process: The parent process hangs up, and the child process is taken over by the init process with pid=1 (wait/waitpid) , until the child process's own life cycle ends and the system reclaims resources and the parent process takes relevant recycling operations

Zombie process:The child process exits, and the parent process does not obtain the child process through wait/waitpid Status, process number occupied by the child process and other resource descriptors still exist, causing harm: for example, the process number is limited, and the process number cannot be released, resulting in that there may be no process number available in the future

**Used in the parent process: pcntl_wait Or the purpose of pcntl_waitpid is to prevent the worker from becoming a zombie process

Function: After using pcntl_wait(), after the child process dies, the parent process will also be stopped**

Finally we pass the picture below Let’s briefly summarize and describe the process of multi-process implementation:

How php manages processes

Process Management-Inter-process Communication

Queue: such as Redis , Recommended

socket: Recommended

Pipeline: The implementation is complex, and the pipe (pipe) exists in the form of a file, and there is a hard disk IO performance bottleneck

Signal: The amount of information carried is small , difficult to manage

Process management-switch to daemon process

Use & implement

php deadloop.php &

The above is the detailed content of How php manages processes. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.