LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   How to kill a task when the task won't die? (https://www.linuxquestions.org/questions/slackware-14/how-to-kill-a-task-when-the-task-wont-die-933266/)

Ook 03-07-2012 12:23 PM

How to kill a task when the task won't die?
 
Slackware 64 bit current, 3.2.2 kernel.

From time to time I need to kill a task. Most of the time this works as expected, but sometimes it does not. I try it from top, nothing happens. I go into htop, and try different kill signals, including 9 sigkill. The task keeps running. I issue kill <pid>, and it still keeps running.

Is there a way to forcibly kill a task, die now, remove it from cpu scheduler queue, just shut up and do it fer cryin' out loud? What do you do when kill won't kill the task, or how do you force a task to be killed no matter what?

Yes, I'm doing this as root.

samac 03-07-2012 12:28 PM

su to root
ps ax
find the misbehaving PID
then
kill -9 $PID or kill -15 $PID
where $PID is the value of the PID

samac

dugan 03-07-2012 12:47 PM

If you can see the task in X (i.e. if it's a window), then run xkill. Your mouse cursor will turn into a skull and crossbones, and you click on the window you want to terminate.

eSelix 03-07-2012 02:25 PM

Are you sure you are tring to "kill -9" a running process and not for example a zombie or process did not restarted automatically? If you encounter this again, show output of "ps -A" with relevant line, before and after killing.

adriv 03-07-2012 06:08 PM

Mostly I use top for terminating processes.
Press k and then type the PID.

escaflown 03-07-2012 07:34 PM

Quote:

Originally Posted by adriv (Post 4621315)
Mostly I use top for terminating processes.
Press k and then type the PID.

same thing here hut with htop.

dive 03-08-2012 02:34 AM

There a couple (probably more) ways that processes refuse to die. They are marked [defunct] or if the process is waiting for hardware.

In the second if hardware is causing a problem sometimes waiting will work. Not always. Sometimes rebooting is the only cure and allows you to for example take out a bad CD/DVD if that was the problem.

Skaperen 03-08-2012 10:46 PM

I have seen processes continue to run (actually use CPU and strace-able) even after I did "kill -KILL" on them from root. But this is very rare (maybe once every 3 years, and it has been 5 years since I last saw this). In all the cases I saw, it was actually a program I wrote that was doing this, and I put nothing in it to try to prevent being killed (I don't even know how to block "kill -KILL"). So I suspect some kernel bug, possibly corruption of the process table. Reboot got rid of it. I reran the program and it killed easily. One perhaps important bit of info: "kill -STOP" really would stop it, and "kill -CONT" would resume it, while "kill -KILL" did nothing at all to it. Strange.

Ook 03-26-2012 03:48 PM

Quote:

Originally Posted by samac (Post 4621075)
su to root
ps ax
find the misbehaving PID
then
kill -9 $PID or kill -15 $PID
where $PID is the value of the PID

samac


I had to kill X the other day,l and kill -9 <pid> did not kill it, neither did kill -15 <pid> kill it. I could not kill it and had to reboot the machine to get rid of it.

What do you do when kill -9/-15 <pid> does not work, other then reboot?

Ook 03-26-2012 03:54 PM

Quote:

Originally Posted by escaflown (Post 4621363)
same thing here hut with htop.

For some reason killing from top and htop does not always work, but exiting them and killing from the command line does. Not sure why.

th0gz19 03-27-2012 08:13 AM

this happened to me, when i kill a process, i still see them in top.
this is how i do it just in case there are duplicate processes. (sometimes happens with my vlc)

# kill -15 `pidof vlc`

or

$ sudo kill -15 `pidof vlc`

if it didn't work, you can substitute "-15" with "-9".


All times are GMT -5. The time now is 08:57 PM.