LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Problem killing process (https://www.linuxquestions.org/questions/linux-newbie-8/problem-killing-process-402646/)

paddyjoy 01-12-2006 05:46 PM

Problem killing process
 
I'm having a bit of trouble killing a process. I was using rpm to remove a package when the terminal windo froze. So I opened up a new terminal and tried to kill the rpm process but with no luck.

Anyone any ideas?

Thanks
Paddy

Code:

[root@paddy ~]# ps -A | grep rpm
32258 pts/1    00:00:00 rpm
[root@paddy ~]# kill -9 32258
[root@paddy ~]# ps -A | grep rpm
32258 ?        00:00:00 rpm
[root@paddy ~]# kill -15 32258
[root@paddy ~]# ps -A | grep rpm
32258 ?        00:00:00 rpm
[root@paddy ~]# kill -9 32258
[root@paddy ~]# ps -A | grep rpm
32258 ?        00:00:00 rpm


btmiller 01-12-2006 08:04 PM

See what state the process is in with "ps aux ". If it's stuck in uninterruptable sleep (state D) it can't be killed, even with kill -9. I've seen this happen with corrupt RPM databases.

paddyjoy 01-12-2006 08:25 PM

Thanks for the info, I actually ended up rebooting my machine because I wasn't able to kill the process!

Paddy

Electro 01-12-2006 09:07 PM

It is better to use kill code 15 before using kill code 9 to force the program to quit. Kill code 15 means terminate, so it is the same as hitting CTRL+C. Sending kill code 9 to a program sometimes turns it into a zombie. A zombie process will not take up resources but a reboot is the only way to get rid of it.

Some processes, you will have to terminate or kill its parent PID.

paddyjoy 01-12-2006 10:45 PM

Thanks I'll remember that for next time. It's annoying when a program like rpm or yum gets zombied like this because it locks some files and the only thing I can do is reboot before I can use that program again.

Paddy

haertig 01-12-2006 11:12 PM

Quote:

Originally Posted by paddyjoy
Thanks I'll remember that for next time. It's annoying when a program like rpm or yum gets zombied like this because it locks some files and the only thing I can do is reboot before I can use that program again.

Zombies happen when a parent forks a child process and the child dies. The child becomes a zombie until either (1) the parent executes a wait() command on the child, or (2) the parent dies. The "parent executes a wait()" scenerio is where the somewhat morbid recommendation that "Parents should reap their dead children" comes from. The next time you zombie a process and can't seem to get rid of it, try logging off and back on again. That may kill the parent, thus freeing the zombie without a reboot. I'm not really familiar with the workings of rpm (I use Debain and dpkg/apt-get), but you can see after your first kill attempt at rpm that it looses it's controlling TTY (was "pts/1" before the kill, then "?" after the kill). I always that zombies showed up in a ps listing as "<defunct>". That's the way it's been for years on many different Unix systems I've worked with. Don't know specifically about Linux though. I haven't been using Linux all that long and haven't looked closely.

paddyjoy 01-12-2006 11:20 PM

Thanks I'm going to try and reproduce it again so that I can test out the different methods of resolving it. After the first kill attempt wasn't successful I killed/closed the terminal window that had frozen, thats when the pts/1 changed to ? I was hoping at the time that killing the parent would also kill the child rpm process. It usually does but maybe this was just a freak occurence!

Paddy


All times are GMT -5. The time now is 02:29 PM.