LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-23-2004, 01:02 AM   #1
sibtay
Member
 
Registered: Aug 2004
Location: U.S
Distribution: Ubuntu
Posts: 145

Rep: Reputation: 15
how to kill <defunct>


my ps -A gives

<application name> <defunct>

i am not able to kill it with kill command

How can i kill such a process
 
Old 08-23-2004, 01:05 AM   #2
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 58
hi
u can try going to the /proc directory and then
delete the directory of the name of the process

this should remove ur defunct process
depends if u r using he /proc filesystem


regards
 
Old 08-23-2004, 01:25 AM   #3
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,275

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
I don't think that's right ... at least I tried this on my system (Slack 10, kernel 2.6.8.1-mm2) and it didn't work, which makes sense given that /proc is just a "window" to the kernel data structures, not direct access to them. What is happening here is that on your system, a process is creating another process and then not "waiting" on its exit status. Because a process can demand the exit status of any of its children, the kernel can't totally get rid of a process until its waited upon (or until the parent exits, orphaning the process and leaving it to be adopted by init, which will clean everything up). This small snippet of Perl demonstrates this for those who are interested (this will leave one of those <defunct> processes, formally called a "zombie").

Code:
#!/usr/bin/perl

print "I am PID $$.\n";

$pid = fork();
if($pid == 0) {
  print "PID $$ about to die and become a zombie.\n";
  die;
}

while(1) {
  sleep(5);
  print "PID $$ still spinning!\n";
}
While the parent runs (which is forever until you nuke it with CTRL+C) the zombie will exist.. Zombies don't actually take up much memory since the kernel gets rid of all the processes' memory except the little bit it may need to report to the parent, should it ever decide to inquire on the exit status of its child. If you could actually clean up zombies by deleting from /proc, it would break a lot of things.
 
Old 08-23-2004, 01:51 AM   #4
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 58
hi
i was telling the above method since i have sen a lot of scripts and programs doing that to kill the processes,
since if we go by
#kill -9
method many of them remain there

so, what other methods do we have to kill such processes
without using
#kill
regards
gaurav
 
Old 08-23-2004, 02:49 AM   #5
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,275

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
I'm not sure what programs you're referring to, but trying to rm a /proc/<pid> entry on my system just results in a load of errors. A zombie process is dead, technically speaking, since it has finished executing, and thus it doesn't really make sense to kill it. The thing is that its parent hasn't waited on it, so it has to keep its entry in the process table, along with a minimal amount of information to be given to the parent if it calls wait. To get rid of the zombie, you'll probably have to kill its parent, causing the zombie to be adopted by init and cleaned up.

BTW I noticed some versions of Firefox leave a zombie netstat process lying around. Is this what you're seeing, sibtay?
 
Old 08-25-2004, 04:17 PM   #6
jonr
Senior Member
 
Registered: Jan 2003
Location: Kansas City, Missouri, USA
Distribution: Ubuntu
Posts: 1,040

Rep: Reputation: 47
To kill a zombie process, issue

ps anl | grep "Z"

and it will show you the zombie processes with both a PID and a PPID heading.

issue kill -9 [PPID number for the zombie process]

and the zombie process should be gone next time you do ps ax.

This kills the parent of the zombie process, as I understand it.
 
Old 02-03-2005, 03:36 PM   #7
brassman
LQ Newbie
 
Registered: Feb 2005
Distribution: Debian, Mandrake
Posts: 1

Rep: Reputation: 0
Found the explanation for the Firefox/Netstat zombie by checking Google groups. Firefox is trying to get more bits for its random number pool by calling netstat, a fairly common kludge on other OSes. Someone just messed a bit on the Linux version.

The Firefox folks are aware of the issue and promised a fix in the next release. random and urandom are more than adequate under Linux, so removing the netstat kludge is an easy fix.
 
Old 02-03-2005, 03:49 PM   #8
jonr
Senior Member
 
Registered: Jan 2003
Location: Kansas City, Missouri, USA
Distribution: Ubuntu
Posts: 1,040

Rep: Reputation: 47
Quote:
Originally posted by brassman
Found the explanation for the Firefox/Netstat zombie by checking Google groups. Firefox is trying to get more bits for its random number pool by calling netstat, a fairly common kludge on other OSes. Someone just messed a bit on the Linux version.

The Firefox folks are aware of the issue and promised a fix in the next release. random and urandom are more than adequate under Linux, so removing the netstat kludge is an easy fix.
That's interesting to know. Thanks for the additional info.
 
Old 02-04-2005, 04:11 AM   #9
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 58
Quote:
Originally posted by brassman
Found the explanation for the Firefox/Netstat zombie by checking Google groups. Firefox is trying to get more bits for its random number pool by calling netstat, a fairly common kludge on other OSes. Someone just messed a bit on the Linux version.

The Firefox folks are aware of the issue and promised a fix in the next release. random and urandom are more than adequate under Linux, so removing the netstat kludge is an easy fix.
thanks for the info but how do we go about removing that netstat kludge

regards
 
Old 11-22-2010, 04:13 AM   #10
sriramraj
LQ Newbie
 
Registered: Jul 2010
Location: Gurgaon
Posts: 6

Rep: Reputation: 0
killing defunct process

There is another way to kill the defunct process. Some times killing the parent also kills the child process. Hope that will be useful for removing defunct processes.

I have tried rebooting the machine.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 a defunct process guarriman Linux - Software 4 05-15-2009 12:09 PM
[cp <defunct>] teeno Linux - Software 2 02-23-2005 05:47 AM
defunct linuxprogrammer Linux - Newbie 1 07-23-2004 01:07 PM
<Defunct> in Tasks cb951303 Slackware 1 02-24-2004 12:56 PM
defunct proceses? JustinHoMi Linux - General 2 10-01-2001 03:01 PM


All times are GMT -5. The time now is 07:08 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration