In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Linux how to kill the defunct process, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
What is a defunct process (zombie process)
In the Linux system, a process ends, but its parent process does not wait for him (calling wait / waitpid), then he will become a zombie process. When you use the ps command to observe the execution status of processes, you can see that the status bar of those processes is defunct. A zombie process is a process that is long dead, but still occupies a slot in the processs table.
But if the parent process of the process has ended first, then the process will not become a zombie process. Because when each process ends, the system will scan all the processes running in the current system to see if any process is a child of the process that has just ended, and if so, the Init process will take over him and become his parent process, thus ensuring that each process will have a parent process. The Init process automatically wait its children, so all processes taken over by Init do not become zombie processes.
II. The mode of operation of the process under Linux
Each Linux process has an entry point (entry) in the process table, and all the information used by the core process to execute the process is stored at the entry point. When you use the ps command to view the process information in the system, you will see the relevant data in the process table. When a new process is created with the fork () system call, the core process assigns an entry point to the new process in the process table and stores the relevant information in the process table corresponding to that entry point. One of these messages is the identification number of its parent process.
The end of the child process and the running of the parent process is an asynchronous process, that is, the parent process can never predict when the child process will end. So will you lose the status information at the end of the child process because the parent process is too busy to wait the child process, or you don't know when the child process will end?
No, I won't. Because Linux provides a mechanism to ensure that as long as the parent process wants to know the state information at the end of the child process, it can get it. This mechanism is: when the subprocess has finished its life cycle, it will execute the exit () system call, and the kernel releases all the resources of the process, including open files, memory occupied, and so on. However, some information is still reserved for it (including process number the process ID, exit code exit code, exit status the terminationstatus of the process, runtime the amount of CPU time taken by the process, etc.), which is retained until the system passes it to its parent process and is not released until the parent process fetches it through wait / waitpid.
In other words, when a process dies, it does not disappear completely. The process terminates and it is no longer running, but there is still some residual data waiting for the parent process to reclaim. When the parent process fork () has a child, it must wait for the child to exit with wait () (or waitpid ()). It is this wait () action that makes the residual data of the child process disappear.
III. The harm of zombie process
If the parent process does not call wait / waitpid, then the retained information will not be released, and its process number will always be occupied, but the process table capacity of the system is limited, and the process number that can be used is also limited. If a large number of zombie processes are generated, the system will not be able to generate new processes because there is no available process number.
Therefore, defunct processes not only occupy the memory resources of the system and affect the performance of the system, but also lead to system paralysis if there are too many of them. Also, because the scheduler cannot select the Defunct process, you cannot delete the Defunct process with the kill command, and the only way is to restart the system.
How to kill the defunct process
A defunct process is a process that is damaged by an error, and the parent and child processes will no longer communicate with each other. Sometimes, they will evolve into "zombie processes" and remain in your system until the system restarts. You can try the "kill-9" command to clear it, but it doesn't work most of the time.
To kill these defunct processes, you have two options:
1. Restart your computer
two。 Read on.
Let's first see if there is a defunct process in the system:
The code is as follows:
$ps-A | grep defunct
Suppose the resulting output is as follows:
The code is as follows:
8328? 00:00:00 mono
8522? 00:00:01 mono
13132? 00:00:00 mono
25822? 00:00:00 ruby
28383? 00:00:00 ruby
18803? 00:00:00 ruby
This means that there are six defunct processes: three mono processes and three ruby processes. These processes may exist because the application is poorly written or the user does something unusual. In my case, there must be a serious problem with the mono C # program I wrote: smile:.
Now, let's look at the ID of these processes and their parent process ID:
The code is as follows:
$ps-ef | grep defunct | more
The output of the above command is as follows:
The code is as follows:
UID PID PPID...
Kenno 8328 6757 0 Mar22? 00:00:00 [mono]
Kenno 8522 6757 0 Mar22? 00:00:01 [mono]
Kenno 13132 6757 0 Mar23? 00:00:00 [mono]
Kenno 25822 25808 0 Mar27? 00:00:00 [ruby]
Kenno 28383 28366 0 Mar27? 00:00:00 [ruby]
Kenno 18803 18320 0 Apr02? 00:00:00 [ruby]
UID: user ID
PID: process ID
PPID: parent process ID
If you use the command "kill-9 8328" to try to kill a process with an ID of 8328, it may not work. To successfully kill the process, you need to execute the kill command ($kill-9 6757) on its parent (ID is 6757). Apply the kill command to the parent ID of all of these processes and verify the results ($ps-A | grep defunct).
After reading the above, have you mastered how to kill the defunct process in Linux? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.