LINUX Zombie process processing

Source: Internet
Author: User
LINUX Zombie process processing 1 What is a zombie process: when a child process ends before the parent process, but the parent process does not recycle the child process, release the resources occupied by the child process, in this case, the child process becomes a zombie process. If the parent process exits and the child process is taken over by init, after the child process exits, init recycles the LINUX Zombie process. 1. what is a zombie process? when the child process ends before the parent process, the parent process does not recycle the child process and releases the resources occupied by the child process. at this time, the child process becomes a zombie process. If the parent process exits and the child process is taken over by init, after the child process exits, init recycles the resources it occupies. 2. how to clear zombie processes: 1. rewrite the parent process and collect dead parts for it after the child process dies. The specific method is to take over the SIGCHLD signal. After a child process dies, it sends a SIGCHLD signal to the parent process. after receiving the signal, the parent process executes the waitpid () function to collect the child process. This is based on the principle that even if the parent process does not call wait, the kernel will send SIGCHLD messages to it, even though the default processing is ignored. if you want to respond to this message, you can set a processing function. 2. kill the parent process. After the death of the parent process, the zombie process becomes an "orphan process". after it passes through to the init process on process 1, init will always be responsible for cleaning up the zombie process. all the zombie processes it generates will also disappear. 3. hazards of zombie processes: in Unix system management, when the ps command is used to observe the execution status of processes, the status bar of some processes is often seen as defunct, this is the so-called "zombie" process. The "zombie" process is a long-dead process, but it still occupies a slot in the processs table ). Because the capacity of the progress table is limited, the defunct process not only occupies the system memory resources, but also affects the system performance. if the number is too large, it will also lead to system paralysis. This section describes how to handle zombie processes in linux: Use ps-efl | awk '$2 ~ /Z/{print} 'Find the Zombie process [root @ rac3 ~] # Ps-efl | awk '$2 ~ /Z/{print} '0 Z root 28212 28201 0 85 0-0 exit Sep25? 00:00:00 [xrdb] Alternatively, use the following statement [root @ rac3 ~]. # Ps-A-ostat, ppid, pid, cmd | grep-e '^ [Zz] 'Z 28201 28212 [xrdb] If there are many zombie processes, use the following statement: ps-efl | awk '$2 ~ /Z/{print "kill-9" $4, $5} 'to generate a script to kill the process. If the kill sub-process is invalid, kill its parent process to solve the problem [root @ rac3 ~] # Kill-HUP 28201 [root @ rac3 ~] # Ps-A-ostat, ppid, pid, cmd | grep-e '^ [Zz]' [root @ rac3 ~] # Toptop-19:38:50 up 21 days, 1 user, load average: 0.00, 0.00, 0.00 Tasks: 173 total, 2 running, 170 sleeping, 0 stopped, 0 zombieCpu (s): 0.3% us, 0.0% sy, 0.0% ni, 99.7% id, 0.0% wa, 0.0% hi, 0.0% si, 0.0% stMem: 4044784 k total, 3606476 k used, 438308 k free, 208260 k buffersSwap: 4192956 k total, 0 k used, 4192956 k free, 2689704 k cached
Related Article

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.