Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

As I've learned from this question, [bracketed] processes listed by the ps aux command are kernel threads. So is there a way to kill them from the command line? If not, I guess the reason for that is to save the user from a higher risk of getting a kernel panic, right?

share|improve this question
add comment

2 Answers 2

up vote 7 down vote accepted

You can not kill kernel threads, or any process that is blocked in the D state, because signals are only delivered when the kernel returns to user mode. Aside from the technical limitation of signal delivery, killing a thread in the middle of kernel code would corrupt the system as the kernel code may be holding an important resource at the time, such as a spin lock or mutex, and killing it would prevent those resources from being released.

If you have a process that is stuck in the D state for a prolonged period of time, then you have a kernel bug. See https://wiki.ubuntu.com/KernelTeam/KernelTeamBugPolicies for tips on reporting it.

share|improve this answer
add comment

Kernel threads are necessary threads created by your Kernel to manage your system.

Not all are necessary but all (most) all beneficial and require mostly no extra resources, there is no reason why one would under normal conditions think about killing a Kernel thread.

Linux Kernel can create an destroy those threads when necessary, you should not worry about them and killing under most circumstances is not something you can do.

share|improve this answer
    
What if I have an thread which is in uninterruptable sleep which blocks a system resource like a device mounted with mount, or other hardware, which I want to release by killing the thread? –  math Dec 12 '11 at 9:57
1  
File a bug against it if you think its useful (and not a glitch with your system) and hope that its solved soon. –  Bruno Pereira Dec 12 '11 at 10:01
    
I would try to find out what is wrong with the mounting before deciding that killing kernel threads was the solution. –  Bruno Pereira Dec 12 '11 at 10:27
    
I am not a kernel hacker but user of certain kernel drivers. Of course I should make a bug report if some device not working properly, but I have to wait then at least half a year, so next ubuntu brings this bugfix. I think that is a valid scenario and the linux kernel should come with the possibility to abort a certain action and release resources (if any were occupied). –  math Dec 12 '11 at 10:37
    
you have unserstand that most likely the kernel thread was initiated by anogher process, so probably there is nothing wrong with that kernel thread except the process that started forgot to close it. i understand what you are saying but i dont think its even advisable to be killing kernel threads. –  Bruno Pereira Dec 12 '11 at 10:47
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.