[comp.sys.att] How do you get rid of <defunct> processes?

lenny@icus.UUCP (Lenny Tropiano) (02/10/88)

I don't know how I do it, but sometimes a process terminates abnormally
and it turns into a ZOMBIE <defunct> process.

  F S   UID   PID  PPID  C PRI NI ADR SZ:RSZ   WCHAN TTY  TIME COMD
  1 Z     0 14275 14273240  80  0                     <defunct>
  1 S     0 14273     1  3  21  0  61 22:  0   4157c  w1  0:00 sh

Now I've tried the usual:

$ kill -9 14273 14275

They don't want to die!  Unfortunately they'll stay there until I reboot,
also it shows up in the "[w]" Windows Manager as if it still exists.  I
toggle to that window and all I get is the WORKING ICON.  And the screen
that was there when I exited... But it doesn't want to die, and I don't
want to reboot.  Is there an easier solution?   And how do they get
created in the first place?
						Thanks,
						-Lenny
-- 
============================ US MAIL:   Lenny Tropiano, ICUS Computer Group
 IIIII   CCC   U   U   SSSS             PO Box 1
   I    C   C  U   U  S                 Islip Terrace, New York  11752
   I    C      U   U   SSS   PHONE:     (516) 968-8576 [H] (516) 582-5525 [W] 
   I    C   C  U   U      S  AT&T MAIL: ...attmail!icus!lenny  TELEX: 154232428
 IIIII   CCC    UUU   SSSS   UUCP:
============================    ...{uunet!godfre, harvard!talcott}!\
                   ...{ihnp4, boulder, mtune, bc-cis, ptsfa, sbcs}! >icus!lenny 
"Usenet the final frontier"        ...{cmcl2!phri, hoptoad}!dasys1!/

david@ms.uky.edu (David Herron -- Resident E-mail Hack) (02/11/88)

In article <260@icus.UUCP> lenny@icus.UUCP (Lenny Tropiano) writes:
>I don't know how I do it, but sometimes a process terminates abnormally
>and it turns into a ZOMBIE <defunct> process.
>
>  F S   UID   PID  PPID  C PRI NI ADR SZ:RSZ   WCHAN TTY  TIME COMD
>  1 Z     0 14275 14273240  80  0                     <defunct>
>  1 S     0 14273     1  3  21  0  61 22:  0   4157c  w1  0:00 sh

The process is in an in-between state ... the process itself has
exitted and all of its' core is deallocated, the only thing left
is a process table slot.  That slot will go away whenever its' parent
does a wait().  "wait()" reaps zombies.  Probably the parent isn't
ready to do any wait()'s?

hmm... I just looked a bit closer at your example.  How in the world
did you get an "sh" with init as it's parent?  Are you running
without the window manager?  (er... /usr/bin/ua?)  (Yes, I already
know that you're running on a Unix PC).

Anyway ... a less drastic way of reaping that zombie is to have the
"sh" exit ... the zombie will then be inheritted by process 1
(init), and since init is doing wait()'s all the time eventually
the zombie will get reaped.  In general, this is the way of getting
zombies to be reaped is to cause them to be inheritted by init
somehow.

He's not tying up much resources.  I have a dim memory, however,
that a zombie can, in some cases, keep some device which can
only be exclusively opened (mag tapes?) from being used by anyone
else until the zombie is reaped.  Also seems like back then I hadn't
realized that the zombie merely had to be inheritted by process
1...
-- 
<---- David Herron -- The E-Mail guy            <david@ms.uky.edu>
<---- or:                {rutgers,uunet,cbosgd}!ukma!david, david@UKMA.BITNET
<----
<---- It takes more than a good memory to have good memories.

pjc@pcbox.UUCP (Paul J. Condie) (02/12/88)

In article <260@icus.UUCP> lenny@icus.UUCP (Lenny Tropiano) writes:
>I don't know how I do it, but sometimes a process terminates abnormally
>and it turns into a ZOMBIE <defunct> process.
>
>  F S   UID   PID  PPID  C PRI NI ADR SZ:RSZ   WCHAN TTY  TIME COMD
>  1 Z     0 14275 14273240  80  0                     <defunct>
>  1 S     0 14273     1  3  21  0  61 22:  0   4157c  w1  0:00 sh
>
>Now I've tried the usual:
>
>$ kill -9 14273 14275
>
>They don't want to die!  Unfortunately they'll stay there until I reboot,
>also it shows up in the "[w]" Windows Manager as if it still exists.  I
>toggle to that window and all I get is the WORKING ICON.  And the screen
>that was there when I exited... But it doesn't want to die, and I don't
>want to reboot.  Is there an easier solution?   And how do they get
>created in the first place?

A process goes through basically three stages startup, run, and 
shutdown (defunct).  The defunct stage is after the program has received
the kill/quit signal (which is why you kill has no effect) and is trying
to close all open files (stdin, ... etc) before it is removed from the
process table.  If you happen to do a ps after the program is killed but
before all clean is done you will see <defunct>.  I have seen your
problem before on a megaframe (which is also a convergent product).
The convergent people told me at the time to ignore the defuncts on the 
megaframe that it would case no harm ( and it didn't).  
In your case it would be anoying if they are still in your "W" window.
Are you running multiple gettys on the console?
Does it only happen with one program?
Does it only happen to programs that use the screen?