Why is my Linux process sleeping?

Why is my Linux process sleeping?

A process enters a Sleeping state when it needs resources that are not currently available. Going into Sleep state means the process immediately gives up its access to the CPU. When the resource the process is waiting on becomes available, a signal is sent to the CPU.

How do you kill a D+ process?

You cannot kill “D” state processes, even with SIGKILL or kill -9. As the name implies, they are uninterruptible. You can only clear them by rebooting the server or waiting for the I/O to respond. It is normal to see processes in a “D” state when the server performs I/O intensive operations.

What’s the difference between uninterrupted sleep and interruptible sleep?

In an interruptible sleep, the process could be woken up for processing of signals. In an uninterruptible sleep, the process could not be woken up other than by issuing an explicit wake_up. Interruptible sleep is the preferred way of sleeping, unless there is a situation in which signals cannot be handled at all, such as device I/O.

Is it possible to strace a process in the uninterruptable sleep state?

Another fun fact about the uninterruptible sleep state is that occassionally it may not be possible to strace a process in this state. The man page for the ptrace system call notes that under rare circumstances attaching to a process using the ptrace system call can cause the traced process to be interrupted.

What happens when ptrace ( 2 ) is in uninterruptible sleep?

If the process is in uninterruptible sleep then the process can’t be interrupted, which will cause the strace process itself to hang forever. Remarkably, it appears that the ptrace (2) system call is itself uninterruptible, which means that if this happens you may not be able to kill the strace process!

What happens when a process is wedged in a sleep state?

Typically when a process is wedged in the uninterruptible sleep state your only recourse is to reboot the system, because there is literally no way to kill the process. One infamous example of this has been Linux with NFS.