Ubuntu – ny way to kill a zombie process without reboot

killprocesszombie

Is there any way to kill a zombie process without reboot? Here is how it happened:

I want to download a 12GB file using torrent. After adding the .torrent file, transmission turned into a zombie process (I tried ktorrent too. Same behavior). Finally I could download the file using µTorrent but after closing the program, it turns into a zombie as well.

I tried using kill, skill and pkill with different options and -9 signal but no success.

After reading some solutions on web, I found out killing the parent can kill the zombie. But killing wine didn't help either.

Is there another way?

Edit:

ps -o pid,ppid,stat,comm

PID  PPID STAT COMMAND
7121  2692 Ss   bash
7317  7121 R+   ps

pstree output:

init─┬─GoogleTalkPlugi───4*[{GoogleTalkPlug}]
 ├─NetworkManager─┬─dhclient
 │                └─{NetworkManager}
 ├─acpid
 ├─amarok───19*[{amarok}]
 ├─apache2───5*[apache2]
 ├─atd
 ├─avahi-daemon───avahi-daemon
 ├─bonobo-activati───{bonobo-activat}
 ├─clock-applet
 ├─console-kit-dae───63*[{console-kit-da}]
 ├─cron
 ├─cupsd
 ├─2*[dbus-daemon]
 ├─2*[dbus-launch]
 ├─desktopcouch-se───desktopcouch-se
 ├─firefox───run-mozilla.sh───firefox-bin─┬─plugin-containe───8*[{plugin-contain}]
 │                                        └─14*[{firefox-bin}]
 ├─gconfd-2
 ├─gdm-binary─┬─gdm-simple-slav─┬─Xorg
 │            │                 ├─gdm-session-wor─┬─gnome-session─┬─bluetooth-apple
 │            │                 │                 │               ├─compiz───sh───gtk-window-deco
 │            │                 │                 │               ├─fusion-icon
 │            │                 │                 │               ├─gdu-notificatio
 │            │                 │                 │               ├─gnome-panel───{gnome-panel}
 │            │                 │                 │               ├─gnome-power-man
 │            │                 │                 │               ├─gpg-agent
 │            │                 │                 │               ├─gwibber-service
 │            │                 │                 │               ├─nautilus
 │            │                 │                 │               ├─nm-applet
 │            │                 │                 │               ├─polkit-gnome-au
 │            │                 │                 │               ├─2*[python]
 │            │                 │                 │               ├─qstardict───{qstardict}
 │            │                 │                 │               ├─ssh-agent
 │            │                 │                 │               ├─tracker-applet
 │            │                 │                 │               ├─trackerd
 │            │                 │                 │               ├─wakoopa─┬─wakoopa
 │            │                 │                 │               │         └─3*[{wakoopa}]
 │            │                 │                 │               └─{gnome-session}
 │            │                 │                 └─{gdm-session-wo}
 │            │                 └─{gdm-simple-sla}
 │            └─{gdm-binary}
 ├─6*[getty]
 ├─gnome-keyring-d───2*[{gnome-keyring-}]
 ├─gnome-screensav
 ├─gnome-settings-
 ├─gnome-system-mo
 ├─gnome-terminal─┬─bash───ssh
 │                ├─bash───pstree
 │                ├─gnome-pty-helpe
 │                └─{gnome-terminal}
 ├─gvfs-afc-volume───{gvfs-afc-volum}
 ├─gvfs-fuse-daemo───3*[{gvfs-fuse-daem}]
 ├─gvfs-gdu-volume
 ├─gvfsd
 ├─gvfsd-burn
 ├─gvfsd-computer
 ├─gvfsd-metadata
 ├─gvfsd-trash
 ├─hald─┬─hald-runner─┬─hald-addon-acpi
 │      │             ├─hald-addon-cpuf
 │      │             ├─hald-addon-inpu
 │      │             └─hald-addon-stor
 │      └─{hald}
 ├─indicator-apple
 ├─indicator-me-se
 ├─indicator-sessi
 ├─irqbalance
 ├─kded4
 ├─kdeinit4─┬─kio_http_cache_
 │          └─klauncher
 ├─kglobalaccel
 ├─modem-manager
 ├─multiload-apple
 ├─mysqld───10*[{mysqld}]
 ├─named───10*[{named}]
 ├─nmbd
 ├─notification-ar
 ├─notify-osd
 ├─polkitd
 ├─pulseaudio─┬─gconf-helper
 │            └─2*[{pulseaudio}]
 ├─rsyslogd───2*[{rsyslogd}]
 ├─rtkit-daemon───2*[{rtkit-daemon}]
 ├─smbd───smbd
 ├─snmpd
 ├─sshd
 ├─timidity
 ├─trashapplet
 ├─udevd───2*[udevd]
 ├─udisks-daemon─┬─udisks-daemon
 │               └─{udisks-daemon}
 ├─upowerd
 ├─upstart-udev-br
 ├─utorrent.exe───{utorrent.exe}
 ├─vnstatd
 ├─winbindd───2*[winbindd]
 ├─wnck-applet
 ├─wpa_supplicant
 └─xinetd

System monitor and top show the zombie process is using resources:

enter image description here

enter image description here

Edit 2:
I think I found something. I tried to logout and saw this message:

enter image description here

Since other torrent clients have th same issue maybe it's something about file size.I'm using ubuntu 10.04 on ext4 partitions.Killing nautilus and sending SIGCHLD signal to it didn't work.

Best Answer

I don't thing zombie process is much of a headache. A zombie process does not take up any resources. It is just that it has it's entry in the process table.

A Zombie process is not an orphan process, it does have a parent.

kill, skill pkill will not work since the process is already killed, just that it's entry has not been removed.

Zombie process can be killed by sending SIGCHLD signal to parent. I think the signal number of SIGCHLD is 17 or 18

If this also fails, then you might want to kill the parent itself.

From Wikipedia on SIGCHLD signal:

When a child process terminates before the parent has called wait, the kernel retains some information about the process to enable its parent to call wait later. Because the child is still consuming system resources but not executing it is known as a zombie process.


EDIT 1: The system resources consumed is mostly the process table entry. If anyone knows if it consumes more than that - memory or CPU cycle, then please add an explanation. AFAIK it hardly takes up any significant system resources.


EDIT 2: Quoting from Wikipedia

On Unix and Unix-like computer operating systems, a zombie process or defunct process is a process that has completed execution but still has an entry in the process table. This entry is still needed to allow the process that started the (now zombie) process to read its exit status.

So the entry is kept so that the parent process can know the exit status because the moment the child exits, the parent is probably not in a state or not ready to read it's exit status.


EDIT 3

Till date I never experienced a zombie process taking 100% of the CPU. Seeing this for the first time.

Try doing a killall utorrent.exe

I can see that there are two instances of utorrent.exe and one of them is zombie. Probably the second one (child). killall should kill the parent since the child(zombie) cannot be killed.


EDIT 4

Looks like the killall did not work since it was giving TERM signal instead of KILL.

Try out killall --signal=KILL utorrent.exe

If this does not work then try killing the process selectivly.

Get the list of utorrent.exe process PID

ps -e | grep -i utorrent

You should get two process like

xxxx ?        aa:bb:cc utorrent.exe defunct
yyyy ?        aa:bb:cc utorrent.exe

So the second one is the parent. Kill it using

kill -9 yyyy

EDIT 5

Please try finding the process's Parent Id by this bash command

cat /proc/{defunctpid}/status | grep -i ppid

in your case is

cat /proc/7298/status | grep -i ppid

If the output comes like

PPid: 1

Then sadly I think you are out of luck. Process Id 1 belongs to init without which your system cannot run

Related Question