1

As manpage of ps states A process with STATUS with the value "D" means "uninterruptible sleep (usually IO)"

Also, I've read: You should use TASK_INTERRUPTIBLE here, otherwise your kernel thread cannot receive signals and you are not able to kill(1) your thread from userspace or use kthread_stop() in the kernel.

If the above is not enough you can read: process status (STAT) of D indicates that the process is in an "uninterruptible sleep" state. In real-world terms, this generally means that it's waiting on I/O and can't/won't do anything - including dying - until that I/O operation completes.

Let's say I run a process that waits IO:

[root@mpinode02 Distros]#  find / -mmin +10 > /dev/null &
[1] 15592

Then I take a look to the status and wchan process

[root@mpinode02 Distros]# ps -C find -ostat,comm,wchan
STAT COMMAND         WCHAN
D    find            sleep_on_buffer

OK, let's see if the process is really uninterrumpible:

[root@mpinode02 Distros]# kill 15592

[1]+  Terminated               time find / -mmin +10 > /dev/null

So, as you can see process with D in the real world was killed, is the man page of ps outdated?

Indeed I see that there is a new kind of state: TASK KILLABLE but I want to know hot to list them. Do you know how to list killable tasks or identify them?

migrated from serverfault.com Aug 26 '13 at 23:46

This question came from our site for system and network administrators.

  • Your example is flawed in that a find command is not always in D state. It might be at the instant that you did the PS. If I see a D consistently for a long time in a process it may be due to some error/or hung driver to an external device. – mdpc Aug 26 '13 at 0:57
  • What could be the sense of a questions site that one (as you comment it seems) MUST know the answer beforehand? I think what your argument is flawed. Yourself say the same that Dennis Kaarsemaker and the same thing that I've discovered by myself (that a process can be in a D STATE for a little period of time) . Do you feel important voting negatively? Be happy and have a nice day. – sebelk Aug 26 '13 at 8:29
5

Welcome to the wonderful world of signals and race conditions.

If you run your ps command a large number of times, you will find that it is occasionally not in D state while you're running the command. While find may spend most of its time waiting for your disk, it definitely doesn't spend all of its time there. And when it's not, your kill signal will be delivered.

So, there is no way to do what you want. ps can iterate over all commands and tell you which ones are killable or not at that time. But when you get to kill, that list will have changed. And even if kill (well, the kernel on behalf of kill) can't deliver a signal immediately, it will do so at the earliest opportunity. So even 'D' state does not mean 'cannot be killed at all', just 'cannot be killed this clock cycle'.

  • Thanks, you'right I've found issuing: watch -n1 -dc 'ps -eo pid,stat,wchan:40,comm |grep D and STATUS of process alternates! – sebelk Aug 25 '13 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.