LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE
User Name
Password
SUSE / openSUSE This Forum is for the discussion of Suse Linux.

Notices


Reply
  Search this Thread
Old 08-03-2007, 09:05 PM   #1
mocean
Member
 
Registered: Sep 2004
Posts: 34

Rep: Reputation: 15
howto kill defunct processes


Hello all here in the message boards..

Would anyone know the best procedure for killing "defunct" processes? I tried killing some but they reappear. I'm not sure how to locate their parent process and stop the "defunct" pid's from coming back.
 
Old 08-04-2007, 01:29 AM   #2
PatrickNew
Senior Member
 
Registered: Jan 2006
Location: Charleston, SC, USA
Distribution: Debian, Gentoo, Ubuntu, RHEL
Posts: 1,148
Blog Entries: 1

Rep: Reputation: 48
use "kill -9 PID" instead of "kill PID"
 
Old 08-04-2007, 10:09 AM   #3
mocean
Member
 
Registered: Sep 2004
Posts: 34

Original Poster
Rep: Reputation: 15
i understand that, but how do identify which process is the parent process, sometimes it's not clear
 
Old 08-05-2007, 12:21 AM   #4
PatrickNew
Senior Member
 
Registered: Jan 2006
Location: Charleston, SC, USA
Distribution: Debian, Gentoo, Ubuntu, RHEL
Posts: 1,148
Blog Entries: 1

Rep: Reputation: 48
A process can't "come back". What happens is either 1) the process never really died, or 2) the parent process is intentionally monitoring it's children and actively spawning another process when the first one got killed. I suspect number one, as programs can handle a term signal without terminating. If it is number two, then the processes are very likely not defunct, as they are respawning other processes.
 
Old 08-05-2007, 03:06 AM   #5
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
You cannot kill a defunct process (a.k.a zombie) as it is already dead.
It doesn't take any resources so it's no big deal but if you really want it to disappear form the process table you need to have its parent procees reaping it.
"pstree" should give you the process hierarchy and "kill -1 <parent-pid>" is sometimes enough for the job.
 
Old 08-05-2007, 09:33 PM   #6
terryxela
Member
 
Registered: Dec 2006
Location: Denver, Colorado, USA
Distribution: SuSE 11.3
Posts: 127

Rep: Reputation: 17
Quote:
Originally Posted by mocean
Hello all here in the message boards..

Would anyone know the best procedure for killing "defunct" processes? I tried killing some but they reappear. I'm not sure how to locate their parent process and stop the "defunct" pid's from coming back.
A couple of comments and the answer to your qestion:

1. If you want to kill a process first find out the pid. For example I want to kill "mythfrontend" process

tdec@amd:~> ps -C mythfrontend
PID TTY TIME CMD
11063 ? 00:01:05 mythfrontend
tdec@amd:~> kill -9 11063

2. Here a great tip from another user (Thxs Bill Dandreta):
Sometimes

kill -9 <pid>

will not kill a process. Run

ps -xal

the 4rd field is the parent process, kill all of a zombie's parents and the zombie dies!

Example

4 0 18581 31706 17 0 2664 1236 wait S ? 0:00 sh -c /usr/bin/gcc -fomit-frame-pointer -O -mfpmat
4 0 18582 18581 17 0 2064 828 wait S ? 0:00 /usr/i686-pc-linux-gnu/gcc-bin/3.3.6/gcc -fomit-fr
4 0 18583 18582 21 0 6684 3100 - R ? 0:00 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/cc1 -quie

18581,18582,18583 are zombies -

kill -9 18581 18582 18583

has no effect.

kill -9 31706

removes the zombies.


Ciao

-=terry(Denver)=-
 
Old 08-05-2007, 11:20 PM   #7
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
Originally Posted by terryxela
kill -9 31706

removes the zombies.
"kill -9" is a last resort command.
First figure out what the 31706 process is, and exercice judgment. For example if it is an application you are currently running, try exiting it using its interface. If it is a service currently used by other people, it may be unwise to abruptly shutting it down.
In any case, try less extreme options before "kill -9". eg:
Code:
kill -1 31706
kill 31706
kill -2 31706
Check the zombies presence after each of these commands.
Use "kill -9" only if the zombies are still there.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to kill <defunct> sibtay Linux - Newbie 9 11-22-2010 03:13 AM
How to kill a defunct process guarriman Linux - Software 4 05-15-2009 11:09 AM
defunct processes in cron bujecas Debian 1 02-07-2006 01:59 PM
Crond running to many processes <defunct> tpfraz Linux - General 1 01-13-2004 07:03 AM
processes showing defunct jpbarto Linux - Software 2 11-05-2003 10:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE

All times are GMT -5. The time now is 06:03 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