Processing of Linux Process status D and Z

Source: Internet
Author: User
Tags tmp file

I have been living in a Linux environment for a long time, and gradually I have a sense of environmental protection. For example, we will write "Wukong" in the logon prompt. I told you not to litter. It is wrong to litter. Why did you throw the stick before I finish talking? The baby box is a treasure. If it is thrown, it will pollute the environment. What if it hits the children? Even if you don't hit the kids, it's not good if you hit the grass... "; put an empty file named" consciously protecting the environment, do not stack garbage "in the user's default directory, and set it as unchangeable with chattr + I; immediately scan the/tmp directory when you see the spam file, and then send a broadcast to notify the spam maker to claim the/tmp file, and warn the spam maker not to take it as an example... we know that the cleanliness of the system environment helps system administrators maintain a good mood, clear thinking, and stable working status.

There is a type of garbage, but it is not so easy to clean, that is, the common state is D (uninterruptible sleep), and the garbage process in the status of Z (zombie. These spam processes are either seeking and not willing, waiting for resources (d) Like a grievance, or being stiff and not dead, waiting for the superdegree (z) Like a grievance ), they are stuck in the CPU run_queue, and the international friends who have never seen my previous blog think that there is another major event of complaints. What should I do? Shot! Kill-9! You are not leaving. However, these two types of spam processes are pervasive. No matter which method they are used, they cannot be killed. Helpless, so we had to reboot, like killing the bird flu, all indiscriminately!

Wukong, we operate and maintain a 24x7 system that serves external customers around the clock. How can we reboot without moving? Our assessment indicators are FOUR 9 (99.99%, and the unplanned downtime cannot exceed 52 minutes and 34 seconds), not four 8 S. If you encounter something, reboot, do you want availability? Besides, now the society has begun to go to harmony. We should try our best to adopt compassionate means for the two spam processes D and Z to solve their difficulties and create conditions, if the problem can be solved and the problem can be eliminated, the problem should be analyzed and solved in detail, killing innocent people will only result in a causal cycle of mutual grievance... $ ^ # $ % # % ^ @#

The poor monk came back to answer the question. I/O resources are not satisfied, which leads to waiting. In the kernel source code fs/proc/array. in C, the text is defined as "d (Disk sleep)",/* 2 */"(from this we can see that D was the disk's first letter ), corresponds to include/Linux/sched. "# define task_uninterruptible 2" in H ". For example, if the NFS server is disabled and the umount directory is not in place, running DF on the NFS client will hold the entire logon session, pressing CTRL + C or Ctrl + z does not help. Disconnect and log on again. Execute PS axf and you will see that the status bit of the DF process has changed to D. Kill-9 cannot be killed. The correct solution is to immediately restore the NFS server and provide services again. The suspended DF process has discovered the resources it is waiting for. Then, the task is completed and automatically disappears. If the NFS server cannot restore the service, delete the NFS mount entry in/etc/mtab before reboot to avoid waiting for resources again when the reboot process routinely calls netfs stop, the system is suspended during restart.

The reason why zombie cannot be killed is that zombie is dead. How can it be called Zombie? The soul is not scattered, and it is natural that there is no solution before life. In Unix/Linux, each process has a parent process named PID (process ID). Correspondingly, the parent process number is called ppid (parent PID ). When a process dies, it automatically closes opened files, discards occupied memory, swap space, and other system resources, returns an exit value to its parent process, and reports a dead message. IfProgramIf there is a bug, there will be a problem in this last step. My son said that I was dead, but I didn't hear it. I didn't immediately accept it, so my son became a zombie. The method of eliminating botnets in Unix/Linux is cool. Execute PS axjf to find the parent process Number of the zombie process (ppid, first column), and first kill its parent, then, the process tianzi Init (its PID is 1, ppid is 0) together to clean up the Parent and Child botnets, Super Death, happy. Note: Sub-processes become botnets only get in the way of sight. If the parent process of a botnet has an active task, you must never rush to death.

 

About zombie process:

These processes have died, but do not release system resources, including memory and some system tables. If there are many such processes, system problems may occur. If the process state shown by PS-el is Z, It is a zombie process.
PS-Ef | grep defunc can identify zombie processes.
Some zombie processes cannot be killed with kill-9 and consume a lot of system resources and cannot be released. If the system sends a message during Shutdown: Some process wouldn't die. this means that some processes cannot be killed by the kill-9 issued by reboot. These are probably zombie processes.

You can use the-L option of PS to obtain more detailed process information.
F (FLAG): The sum of a series of numbers, indicating the current state of the process. The meanings of these numbers are:
00: If it is displayed separately, the process has been terminated.
01: A process is a part of the core process and resident in the main memory of the system. Such as sched, vhand, and bdflush.
02: parent is tracing process.
04: Tracing parent's signal has stopped the process; the parent is waiting (ptrace (s )).
10: A process enters sleep state when its priority is lower than or equal to 25, and cannot be awakened by a signal, for example, waiting for an inode to be created
20: The process is loaded into the primary memory (primary memory)
40: The process is locked in the primary memory and cannot be replaced before the transaction is completed.
S (State of the process)
O: the process is running as a processor.
S: Sleeping)
R: runable)
I: idle)
Z: Zombie)
T: trace status (traced)
B: The process is waiting for more memory pages.
C (CPU usage): Estimation of CPU utilization

To clear zombie (zombie) processes, you can use the following methods:
1> kill-18 ppid (ppid is its parent process)
This signal tells the parent process that the child process has died. Please reclaim the resources allocated to it.
2> if not, check whether the parent process can be terminated (if not required by the parent process ). First, check that the parent process has no other sub-processes. If yes, you may need to kill other sub-processes, that is, brother processes. The method is:
Kill-15 pid1 pid2 (pid1, pid2 is another sub-process of the parent process of the zombie process ).
Then kill the parent process: Kill-15 ppid

In this way, the zombie process may be completely killed.

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.