Orphan process with zombie process

Source: Internet
Author: User

1. Basic Concepts:

Orphan process: The parent process exits, but its child processes are still running, so these child processes are called orphan processes, and the orphan process is adopted by the INIT process and treated as a aftercare;

Zombie Process: A process that has been terminated, but whose parent process has not yet been aligned, is called a zombie process, and the PS command status is z-process;

Aftercare: The kernel holds a certain amount of information for each terminating child process, which includes at least the process ID, the terminating state of the process, and the total CPU time used by the process. If the parent process does not use wait or waitpid to get information about terminating the child process, the information will be saved until the parent process is processed before releasing the resources it still occupies;

2. What is the harm:

Orphan process: The orphan process will be adopted by the INIT process and treated in the aftermath, so the orphan process is not harmful;

Zombie Process: If the parent process has not executed wait or waitpid, then the kernel will keep the state information of the child process, if there are a large number of zombie processes in the system, may result in the number of available process is less and even exhausted, so should avoid the emergence of the zombie process;

3. Workaround:

(1) The parent process waits for the child process to end with wait or waitpid;

(2) When the child process ends, the SIGCHLD signal is sent to its parent process, so the parent process can register SIGHLD signal processing and call wait or waitpid in the processing function;

(3) Fork two times, that is, the fork to produce the child process, the child process fork to generate the grandchild process, the child process ends, the main process uses wait or waitpid wait for the child process, and the sun process after its parent process exits, become an orphan process, was init adoption;

Another: If there are a large number of zombie processes in the current system, you need to find their parent process to kill their parent process, these zombie processes will be adopted by the Init and aftercare;

Orphan process with zombie process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.