Digital Marketing

How to clean up zombie process in Linux

A zombie process or defunct process is a process that has completed execution (via the exit system call) but still has an entry in the process table: it is a process in the "Terminated state". This occurs for child processes, where the entry is still needed to allow the parent process to read its child's exit status: once the exit status is read via the wait system call, the zombie's entry is removed from the process table and it is said to be "reaped". A child process always first becomes a zombie before being removed from the resource table.

Zombies can be identified in the output from the Unix ps command by the presence of a "Z" in the "STAT" column.

$ ps aux | grep Z
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
i88ca        507  0.0  0.0      0     0 ?        Z    14:48   0:00 [xscreensaver] <defunct>
root        1420  0.0  0.0      0     0 ?        Z    Jan20   0:00 [xrdp-chansrv] <defunct>

To remove zombies from a system, the SIGCHLD signal can be sent to the parent manually, using the kill command. If the parent process still refuses to reap the zombie, the next step would be to remove the parent process.

When a process loses its parent, init becomes its new parent. init periodically executes the wait system call to reap any zombies with init as parent.

Comments

Popular posts from this blog

MySQL Sandbox with the Sakila sample database