LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-11-2008, 05:26 PM   #1
klauswunderlich
LQ Newbie
 
Registered: Jan 2008
Distribution: openSuse, Debian, Ubuntu
Posts: 22

Rep: Reputation: 15
What to do when kill -9 PID doesn't work


Due to a buggy external disk, programs accessing data thereon have a tendency not to respond to a kill -9. I thought -9 was putting it fairly strongly, but is there some other force mechanism? It's accessing the files read-only, so I hope it wouldn't corrupt the file system (I'm currently trying to copy the data off it).
 
Old 05-11-2008, 06:10 PM   #2
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
Those processes are "not listening", thus the kill command cannot reach them. As a workaround you can try and umount the volume with -l option (see man umount).
 
Old 05-12-2008, 08:36 AM   #3
dickgregory
Member
 
Registered: Oct 2002
Location: Houston
Distribution: Arch, PCLinuxOS, Mint
Posts: 257

Rep: Reputation: 34
I think there must be something wrong with the system other than a berserk process. It is my understanding the the -9 signal kills the process with no action required, or even permitted from the process. I don't think that the process needs to be listening in order to be killed. The OS handles it and forces termination, regardless of what the offending process is or is not doing.

Unfortunately, I'm still newbie enough not to know what to look for in your case. Have you tried restarting, or copying your files using a different distro?
 
Old 05-13-2008, 12:32 AM   #4
klauswunderlich
LQ Newbie
 
Registered: Jan 2008
Distribution: openSuse, Debian, Ubuntu
Posts: 22

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by dickgregory View Post
I think there must be something wrong with the system other than a berserk process. It is my understanding the the -9 signal kills the process with no action required, or even permitted from the process. I don't think that the process needs to be listening in order to be killed. The OS handles it and forces termination, regardless of what the offending process is or is not doing.

Unfortunately, I'm still newbie enough not to know what to look for in your case. Have you tried restarting, or copying your files using a different distro?

This is all now academic hypothesis, but I believe because the mount process doesn't ever return, it assumes a zombie state. To kill/reap a zombie process like mount, I think I have to kill init (not desirable!). If someone in the know could better explain how reaping zombie processes work, I'd be grateful.

As for debugging the actual problem, it turns out it was the usb -> IDE controller that the disk was connected to. Hardware error.
 
Old 05-13-2008, 02:30 AM   #5
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
Umm ... you can't kill init. The kernel won't let you. When a parent processes predeceases its children (or dies without waiting for completed children), init adopts them and cleans them up. This is part of the reason it's so vital for init to hang around (along with respawning ttys and the like).

However, that doesn't sound like the problem here. With dodgy hardware, processes trying to access it are often left in the D state (check top or ps). D is essentially uninterruptable sleep. This generally indicates that the process is executed in kernel mode, and because the kernel has allocated some resource for it (e.g. an I/O buffer), it cannot be killed because doing so could cause inconsistencies in the system. Therefore the process becomes unkillable, because its sudden disappearance could really trip up the kernel (e.g. the I/O buffer would be reallocated when the process died, so the hardware might write to an no-longer-valid spot in memory, causing general mayhem). Therefore the kernel "protects" it so that even kill -9 won't do it in. This is ordinarily supposed to be a very temporary state for a process, but when I/O hardware starts going dodgy, the operation the kernel is waiting on may take a long time or possibly never complete.

When this happens, you basically have two options:

(1) Hope that eventually some timer or interrupt will tell the kernel that this I/O operation just isn't happening. When that happens, the kernel will return an error to the process, move it out of D state, deliver the SIGKILL that you sent with kill -9, and the process will die. Depending on the nature of your flaky hardware, this may never happen.

(2) Shutdown the system, disconnect the fauly hardware, and power back on.
 
Old 05-14-2008, 01:03 AM   #6
klauswunderlich
LQ Newbie
 
Registered: Jan 2008
Distribution: openSuse, Debian, Ubuntu
Posts: 22

Original Poster
Rep: Reputation: 15
Uh, I know you can't kill init; my attempt at humour. (Huge kick in the comedy teeth there...)

Thanks for the excellent explanation in your second paragraph. I was using solution #2 until I got all the data off the disk.
 
Old 09-11-2011, 07:14 AM   #7
synthakai
LQ Newbie
 
Registered: Sep 2011
Posts: 4

Rep: Reputation: Disabled
I believe there is a signal that tells process to interrupt all its I/O attempts. Therefore the process becomes able to receive kill -9 from the system. I can't remember the exact signal to interrupt I/O, but it once (several years ago) helped me to kill k3b which hooked up while writing a disc.
 
Old 10-11-2011, 08:47 PM   #8
top
LQ Newbie
 
Registered: Oct 2011
Location: Kiev
Distribution: CentOS, Debian, Ubuntu, FreeBSD, Solaris
Posts: 3

Rep: Reputation: Disabled
OK, but what if I don't care to kill the process, and just want to release the terminal from it, so that to get back access to other shell jobs running in the background in the same session?

The problem is the hung process is in the foreground (active job in shell) and it doesn't respond to Control-C, Control-Z or whatever.

Note: I've got another terminal available, so I can issue any commands in the system.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
kill <pid> does not do anything moskito01 Linux - General 9 08-25-2009 12:20 PM
kill -9 and respawns as new pid jago25_98 Linux - Software 3 06-18-2007 02:05 PM
kill pid ekdya Debian 3 04-18-2006 05:04 PM
kill pid.... won't work with 'pid' variable given.. sachitha Programming 6 03-06-2006 07:48 PM
when kill -9 PID wont work bleunuit Linux - Software 2 08-06-2004 11:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration