본문 바로가기

개발/서버

How to kill zombie process [closed]

I launched my program in the foreground (a daemon program), and then I killed it with

kill -9

, but I get a zombie remaining and I m not able to kill it with

kill -9

. How to kill a zombie process?

If the zombie is a dead process (already killed), how I remove it from the output of

ps aux

?

root@OpenWrt:~# anyprogramd &
root@OpenWrt:~# ps aux | grep anyprogram
 1163 root      2552 S    anyprogramd
 1167 root      2552 S    anyprogramd
 1169 root      2552 S    anyprogramd
 1170 root      2552 S    anyprogramd
10101 root       944 S    grep anyprogram
root@OpenWrt:~# pidof anyprogramd
1170 1169 1167 1163
root@OpenWrt:~# kill -9 1170 1169 1167 1163
root@OpenWrt:~# ps aux |grep anyprogram
 1163 root         0 Z    [cwmpd]
root@OpenWrt:~# kill -9 1163
root@OpenWrt:~# ps aux |grep anyprogram
 1163 root         0 Z    [cwmpd]


2) Here a great tip from another user (Thxs Bill Dandreta):
Sometimes

kill -9 <pid>

will not kill a process. Run

ps -xal

the 4rd field is the parent process, kill all of a zombie’s parents and the zombie dies!

Example

4 0 18581 31706 17 0 2664 1236 wait S ? 0:00 sh -c /usr/bin/gcc -fomit-frame-pointer -O -mfpmat
4 0 18582 18581 17 0 2064 828 wait S ? 0:00 /usr/i686-pc-linux-gnu/gcc-bin/3.3.6/gcc -fomit-fr
4 0 18583 18582 21 0 6684 3100 - R ? 0:00 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/cc1 -quie

18581

,

18582

,

18583

are zombies –

kill -9 18581 18582 18583

has no effect.

kill -9 31706

removes the zombies.


2) Here a great tip from another user (Thxs Bill Dandreta):
Sometimes

kill -9 <pid>

will not kill a process. Run

ps -xal

the 4rd field is the parent process, kill all of a zombie’s parents and the zombie dies!

Example

4 0 18581 31706 17 0 2664 1236 wait S ? 0:00 sh -c /usr/bin/gcc -fomit-frame-pointer -O -mfpmat
4 0 18582 18581 17 0 2064 828 wait S ? 0:00 /usr/i686-pc-linux-gnu/gcc-bin/3.3.6/gcc -fomit-fr
4 0 18583 18582 21 0 6684 3100 - R ? 0:00 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/cc1 -quie

18581

,

18582

,

18583

are zombies –

kill -9 18581 18582 18583

has no effect.

kill -9 31706

removes the zombies.


'개발 > 서버' 카테고리의 다른 글

UNIX IP Stack Tuning Guide v2.7  (0) 2015.09.10
죽은 프로세스 살리기  (0) 2015.09.10
DNS 시스템에 대한 위협에 대해  (0) 2015.02.03
apache 디폴트 설정  (2) 2014.12.09
ssh scp remote file downloads  (0) 2014.12.08