Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop 'uninterruptible' process on Linux?

I have a VirtualBox process hanging around which I tried to kill (KILL/ABORT) but without success. The parent pid is 1 (init).

top shows the process as D which is documented as "uninterruptible sleep".

strace shows up nothing.

How can I get rid of this? It prevents me from unloading the VirtualBox kernel driver to load a newer one.

like image 950
Tilo Prütz Avatar asked Apr 20 '09 09:04

Tilo Prütz


People also ask

What causes uninterruptible sleep Linux?

An Uninterruptible sleep state is one that won't handle a signal right away. It will wake only as a result of a waited-upon resource becoming available or after a time-out occurs during that wait (if the time-out is specified when the process is put to sleep).

How do I kill a sleeping process in Linux?

Terminating a Process using kill Command You can use either the ps or pgrep command to locate the PID of the process. Also, you can terminate several processes at the same time by entering multiple PIDs on a single command line. Lets see an example of kill command. We would kill the process 'sleep 400' as shown below.

What causes uninterruptible sleep?

One of the curious features of Unix systems (including Linux) is the "uninterruptible sleep" state. This is a state that a process can enter when doing certain system calls. In this state, the process is blocked performing a sytem call, and the process cannot be interrupted (or killed) until the system call completes.


2 Answers

Simple answer: you cannot.

Longer answer: the uninterruptable sleep means the process will not be woken up by signals. It can be only woken up by what it's waiting for. When I get such situations eg. with CD-ROM, I usually reset the computer by using suspend-to-disk and resuming.

like image 96
jpalecek Avatar answered Oct 08 '22 22:10

jpalecek


Killing an uninterruptible process succeeds, it just doesn't do so immediately. The process won't disappear until it actually receives the signal. So sending a signal alone is not enough to get rid of the process, you also have to wake it up from uninterruptible sleep.

Tanel Poder has written a great guide to analyse D state processes. It is very typical that this state is caused by incomplete I/O, e.g. network failure. slm has posted some very useful pointers on superuser how to unjam the network I/O, and also about the problem itself.

Personally, when dealing with Windows on VirtualBox, and even with wine, I often run into this problem because of a cdrom I/O that never completes (I guess its some sort of disc presence check). ATA devices can be reset, which likely will unjam the process. For instance, I'm using the following little script to reset both my optical drives, unjamming the processes they are blocking:

echo 1 > /sys/block/sr0/delete echo 1 > /sys/block/sr1/delete echo "- - -" > /sys/class/scsi_host/host7/scan 
like image 32
Carsten Milkau Avatar answered Oct 09 '22 00:10

Carsten Milkau