Using preap to kill defunct processes on Solaris

Once in a while you will see some strange processes with <defunct> instead of a process name. This happens when a child process terminates, but the parent process isn't interested in the outcome because it didn't waited for the childs response.

Using ps lets check for our processes and only output the defunct processes

# ps -ef | grep defunct
root 84838 426    0 -        ?     0:00 <defunct>
root 27841 27840  0 09:32:54 pts/1 0:00 grep defunct

A kill -9 to this process is without effect. Obviously, a zombie will go away when you terminate the parent process, but that isnt always an option.

However with later releases of Solaris you can reap such processes manually. The preap forces the parent to reap the child. For example:

# preap 84838
84838: exited with status 0

This will cause the process to exit, and the kernel can then free up the resources that were allocated by that process.