How to kill the D status process? [ZT] "Turn"

Source: Internet
Author: User

Transferred from: http://blog.csdn.net/chinalinuxzend/article/details/4288791

[-]

    1. How to kill the D-state process ZT
      1. Related Posts

Original sticker: http://www.xclinux.cn/?p=752

How to kill the D status process? [ZT]

The status is D (uninterruptible sleep), and the status is Z (Zombie) These garbage processes are either begging or not, like a disgruntled woman waiting for resources (D), or stiff and immortal, waiting for the cross-over (Z) like ghost, they are stuck in the CPU run_queue, The Load Average the old high Old high, did not read my previous blog of the International friends also thought here resentment again what big thing. What to do? Shoot! kill-9! Let's see if you go. But the two kinds of garbage process is invulnerable, no matter what kind of marksmanship can not kill them. Helpless, had to reboot, like to destroy the avian flu as indiscriminately all culling!
The basic idea is to modify the kernel, traverse the list of processes, find a process in the D state, and convert its state to another state to kill it.
This is a rather rude method that may cause some undesirable consequences and is not considered for the time being. For the exact knowledge that there is no use, do not do clean-up work, in the D-state how to kill the process, is indeed very effective.
Kernel Module Code:
—————-KILLD.C —————-
#include <linux/init.h>
#include <linux/module.h>
#include <linux/sched.h>//for_each_process
Module_license ("BSD");
static int pid =-1;
Module_param (PID, int, s_irugo);
static int killd_init (void)
{
struct task_struct * p;
PRINTK (kern_alert "Killd:force D status process to death/n");
PRINTK (Kern_alert "killd:pid=%d/n", PID);
Read_lock (&tasklist_lock);
For_each_process (p) {
if (p->pid = = pid) {
PRINTK ("killd:found/n");
Set_task_state (P, task_stopped);
PRINTK (Kern_alert "Killd:aha, Dead already/n");
return 0;
}
}
PRINTK ("not Found");
Read_unlock (&tasklist_lock);
return 0;
}
static void Killd_exit (void)
{
PRINTK (Kern_alert "killd:bye/n");
}
Module_init (Killd_init);
Module_exit (Killd_exit);
-–makefile ————
Obj-m: = KILLD.O
Compiling the module
Make-c yourkerneltree m= ' pwd ' modules
The process number of the D state is provided when the module is inserted, and it can be converted to the stopped state, which can be killed using normal kill.
./insmod./killd.ko pid=1234

How to kill the D status process? [ZT] "Turn"

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.