Linux Zombie Process

Source: Internet
Author: User
Tags terminates

Because the end of the child process and the run of the parent process are an asynchronous process, the parent process can never predict when the child process will end. So will it be because the parent process is too busy to wait for the child process, or does it not know when the child process ends and loses the state information at the end of the child process? No. Because UNIX provides a mechanism that can be obtained if the parent process wants to know the state information at the end of the child process. The mechanism is that when each process exits, the kernel frees all of the resources of the process, including open files, memory usage, and so on. However, it still retains certain information (including process number, exit status, run time, etc.). It is not released until the parent process passes wait/waitpid. However, this causes the problem, if the process does not call Wait/waitpid, then the reservation of the piece of information will not be released, its process number will always be occupied, but the system can use the process number is limited, if a large number of zombie process generated, The system cannot produce a new process because no process number is available. This is the threat to the zombie process and should be avoided.

The zombie process includes resources such as the ID number of the process, the exit status of the process, the CPU time the process is running, and so on. As a result, when the process terminates, it reclaims all of the kernel's memory allocated to it, closes all files it opens, and so on, but retains only a few of the above information for use by the parent process. The parent process can use system wait/waitpid, such as a, to clean up the child process and do some finishing work.

If a process terminates itself, after calling exit to clean up resources such as the associated content file, it enters the zombie state, and its parent process calls WAIT4 to reclaim the task_struct, but if the parent process has not called WAIT4 to release the task_ of the child process struct, the question is coming, who task_struct to recycle it? No one is ever, unless the parent process terminates, the zombie process is taken over by the Init process and then called WAIT4 to reclaim the process descriptor. If the parent process is running all the time, the zombie will always consume system resources, and no semaphore can be released with Kill. This is scary because countless zombie processes on the server can cause the machine to hang up.

In fact, the process descriptor is not retracted task_struct, also called the process table entry

Linux 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.