zombie process

dear friends,

in an interview they asked me what is zombie process. how we can identifying these process.if can you kill all zombie process.

ps -elf | grep -w Z

Regards

You cannot kill zombie processes as they are already dead.

If you have zombie processes you can

  1. try to restart parent process
  2. kill all processes kill -9 -1

Reboot is the best solution to get rid of this.

#2 is quite harsh and certainly much worse than having dead processes consuming no resources like zombies are.

yes I agree but unfortunally today we my mentor tought just that two ways

Tell your mentor unplugging the server power supply would work too ...

NAME
preap � force a defunct process to be reaped by its parent
Synopsis
preap [-F] pid...Description
A defunct (or zombie) process is one whose exit status has yet to be reaped by its parent. The exit status is reaped by way of the wait(3C), waitid(2), or waitpid(3C) system call. In the normal course of system operation, zombies can occur, but are typically short-lived. This can happen if a parent exits without having reaped the exit status of some or all of its children. In that case, those children are reparented to PID 1. See init(1M), which periodically reaps such processes.

An irresponsible parent process can not exit for a very long time and thus leave zombies on the system. Since the operating system destroys nearly all components of a process before it becomes defunct, such defunct processes do not normally impact system operation. However, they do consume a small amount of system memory.

preap forces the parent of the process specified by pid to waitid(3C) for pid, if pid represents a defunct process.

preap attempts to prevent the administrator from unwisely reaping a child process which might soon be reaped by the parent, if: