Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I put process into "uninterruptible sleep"?

I'm testing some functionality to monitor processes and I need to emulate long core dump with determined "delay" (for example I need to make a process to "dump core" for 30 seconds). I'm noticed that process that dumping a core is in uninterruptible sleep, so it can't be killed with SIGKILL, but when I'm trying to emulate this behavior using pipe commands that receives coredump I can easily kill such process. So is there some way to make process to get into uninterruptible sleep (with such status in ps) and make it ignore the SIGKILL?

like image 516
gordon-quad Avatar asked Feb 19 '23 06:02

gordon-quad


1 Answers

Most proper way is to use freezer cgroup. It puts process to uninterruptible sleep in case of FROZEN cgroup state.

# mkdir /sys/fs/cgroup/freezer
# mount -t cgroup -ofreezer freezer /sys/fs/cgroup/freezer
# mkdir /sys/fs/cgroup/freezer/frozen
# echo FROZEN > /sys/fs/cgroup/freezer/frozen/freezer.state
# echo `pidof you_process` > /sys/fs/cgroup/freezer/frozen/tasks

To put again to interruptible sleep, just change cgroup state to THAWED.

like image 75
AlexeyPerevalov Avatar answered Feb 28 '23 09:02

AlexeyPerevalov