Intentionally stop a process from responding

Mikk3lRo asked:

Is there any way to intentionally prevent a process from responding – ie. not close or kill it, but stop it dead in it’s track, so it immediately stops processing anything?

I’ve often found myself wanting to force a process into a non-responsive state to test some sort of handler for when this really happens for whatever reason.

Currently I’m working on centos 5.5, and specifically want to prevent named from responding – it happens occasionally under “normal conditions” (ie. cause unknown), and I need to react to that… but testing is rather difficult when I need to wait (for weeks) for it to happen randomly.

I suppose a good indicator that the process is dead would be that strace -p 1234 is silent.

A generic solution is preferred, but if you have any ideas that would cover just this specific case, please do post an answer anyway.

My answer:


You can suspend a process by sending it SIGSTOP, and resume it by sending SIGCONT.

kill -STOP <pid>

and

kill -CONT <pid>

respectively.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.