Tag Archives: zombie

[Tip | Ubuntu] zombie 프로세스 제거

프로세스를 종료 하였음에도 메모리가 정상해지 되지 않았거나 프로세스 엔트리에 남아 실행되고 있는 경우 이를 제거 하는 방법을 정리한다.


테스트서버 : Ubuntu22.04
작성일 : 2023-01-03

Zombie

On Unix operating systems, a zombie process or defunct process is a process that has completed execution but still has an entry in the process table, allowing the process that started it to read its exit status. In the term's colorful metaphor, the child process has died but has not yet been reaped.

When a process ends, all of the memory and resources associated with it are deallocated so they can be used by other processes. However, the process's entry in the process table remains. The parent is sent a SIGCHLD signal indicating that a child has died; the handler for this signal will typically execute the wait system call, which reads the exit status and removes the zombie. The zombie's process ID and entry in the process table can then be reused. However, if a parent ignores the SIGCHLD, the zombie will be left in the process table. In some situations this may be desirable, for example if the parent creates another child process it ensures that it will not be allocated the same process ID.

1> zombie 프로세서 확인

top
# ----------------------------------------
top - 10:13:56 up 4 days, 16:19,  2 users,  load average: 0.08, 0.53, 3.08
Tasks: 246 total,   1 running, 245 sleeping,   0 stopped,   0 zombie
%Cpu(s):  2.2 us,  0.7 sy,  0.0 ni, 97.1 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
# ----------------------------------------

zombie의 숫자가 1이상이라면 pid 를 확인하여 kill 해야한다.


2> pid 확인

ps axo stat,ppid,pid,comm | grep -w defunct
# ----------------------------------------
Z     544478  545217 ruby <defunct>
Z     544478  547937 ruby <defunct>
# ----------------------------------------

3> kill 프로세스

kill -9 544478