For catastrophe testing scenarios on out server environment we're looking for an easy way to make a process stuck in D (uninterruptible sleep) state.
Any easy ways? An example C sample code would be a plus 🙂
Edit – the first answer is semi-correct, as the process is shown to be in D state, but it still receives signals and can be killed
Best Answer
I had the same problem and resolved it by creating a kernel module that gets stuck in D state.
As I don't have any experience in modules, I took the code from this turorial with some modifications found someplace esle.
The result is a device on /dev/memory that gets stuck on read but can be waken up writting on it (it needs two writes, I don't know why but I don't care).
To use it just:
To unblock, from another terminal:
Makefile:
Code for memory.c: