You are not logged in.

#1 2010-05-25 08:01:59

Cdh
Member
Registered: 2009-02-03
Posts: 1,098

Can you get rid of defunct / stuck processes?

Hi

Say you have a process that blocks access to a device e.g. a v4l2 device.
Say also that this process is a zombie and is defunct. Therefore kill -9 will not work on the process no matter how often you try.

What can you do to access the device again (better: to kill the process) without rebooting the system?

Last edited by Cdh (2010-05-25 23:52:18)


฿ 18PRsqbZCrwPUrVnJe1BZvza7bwSDbpxZz

Offline

#2 2010-05-25 10:20:17

hbekel
Member
Registered: 2008-10-04
Posts: 311

Re: Can you get rid of defunct / stuck processes?

Afaik, there's nothing you can do except to try and kill the parent process. And in case the parent process is init (PID 1), nothing but a reboot will fix that.

Offline

#3 2010-05-25 20:58:20

Cdh
Member
Registered: 2009-02-03
Posts: 1,098

Re: Can you get rid of defunct / stuck processes?

That sucks.
I mean, with root there should be a switch kill -9 --force --i-really-want-to-no-matter-what-consequences

The same with modules that don't work anymore but still block access to the hardware while rmmod -f doesn't work.

chris@chrispc ~ % kill -9 5403
chris@chrispc ~ % ps -x | grep 5403
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
 5403 ?        Ds     0:03 guvcview
 6507 pts/0    S+     0:00 grep --color=auto 5403
chris@chrispc ~ % lsof | grep /dev/video0
guvcview  5403 chris  mem       CHR       81,0              5300 /dev/video0
guvcview  5403 chris    6r      CHR       81,0      0t0     5300 /dev/video0
chris@chrispc ~ %

FFFFUUU


฿ 18PRsqbZCrwPUrVnJe1BZvza7bwSDbpxZz

Offline

#4 2010-05-25 21:29:43

ataraxia
Member
From: Pittsburgh
Registered: 2007-05-06
Posts: 1,553

Re: Can you get rid of defunct / stuck processes?

That is not a defunct process - those are marked with a 'Z' instead of 'D'. This one is stuck waiting for something. If it ever wakes up at all, strace might be useful, but this is more like a kernel-level sleep, as if /dev/video0 is wedged.

Offline

#5 2010-05-25 23:59:33

Cdh
Member
Registered: 2009-02-03
Posts: 1,098

Re: Can you get rid of defunct / stuck processes?

Was mistaken and edited the title, thanks.
The problem is still the same. I know that whatever the process is waiting for is not going to happen...
I cannot believe there is no mechanism to force-kill these things... This happens to me not really often but yet often enaugh that I miss this functionality.

Another example was when I was trying disabling of one CPU core with echo 0 > /sys/devices/system/cpu/cpu1/online

root  74570.0  0.2   5792  2488 ? D    10:58   0:00 zsh
root  76920.0  0.2   5808  2484 pts/1 D+   11:02   0:00 -zsh
root  77580.0  0.2   5808  2492 ? D    11:03   0:00 -zsh
root  78240.0  1.2  38108 12492 ? D    11:04   0:00 gnome-system-monitor
chris  78820.01.2  63904 12848 ?  D    11:05   0:00 gnome-system-monitor
root  81000.0  0.0   1668   448 pts/5 D+   11:07   0:00 rmmod powernow_k8

Yea, maybe it doesn't work with my CPU but that is no reason to block all the processes and give me no control to kill them...


฿ 18PRsqbZCrwPUrVnJe1BZvza7bwSDbpxZz

Offline

#6 2010-05-26 00:48:47

tavianator
Member
From: Waterloo, ON, Canada
Registered: 2007-08-21
Posts: 859
Website

Re: Can you get rid of defunct / stuck processes?

Cdh wrote:

Was mistaken and edited the title, thanks.
The problem is still the same. I know that whatever the process is waiting for is not going to happen...
I cannot believe there is no mechanism to force-kill these things... This happens to me not really often but yet often enaugh that I miss this functionality.

There isn't such a mechanism (kill -9 --force --i-really-want-to-no-matter-what-consequences) because you really actually don't want to kill a process in state D.  Such processes are in uninterruptible kernel sleep, and are designed to stay there for very short amounts of time, although in practice, bad hardware / kernel bugs / gigantic writes can keep it there for a long time.  They are in this state in order for the kernel to be able to ensure well-defined concurrency behaviour, and thus giving even root the ability to kill them would allow the user to invoke undefined behaviour in the kernel, which could lead to memory or filesystem corruption, and other bad things.

There is built-in kernel functionality (khungtaskd) which kills these processes eventually.

(EDIT: not being a kernel programmer myself, this is just my interpretation of the docs, and of the fact that if it were safe to kill these processes yourself, Linux would probably let you.)

Last edited by tavianator (2010-05-26 00:50:52)

Offline

#7 2022-05-17 10:57:49

LordAlveric
Member
Registered: 2021-11-05
Posts: 2

Re: Can you get rid of defunct / stuck processes?

Old thread. but now zps is your friend.

zps -l -- list the zombie process
zps -x -- nuke all zombie process from orbit. It's the only way to be sure.

Offline

#8 2023-01-16 16:45:32

Xelvet
Member
Registered: 2014-02-20
Posts: 88

Re: Can you get rid of defunct / stuck processes?

riiiight now zombie
is my only friend..
(I’ll reap all you sow)

Offline

#9 2023-01-16 16:59:51

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,296

Re: Can you get rid of defunct / stuck processes?

Closing this old thread.

Offline

Board footer

Powered by FluxBB