0

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.

Mikk3lRo
  • 183
  • 1
  • 7
  • 3
    Is `kill -19` (aka `kill -stop`) out of the question? – MadHatter Jun 03 '15 at 13:31
  • 1
    I didn't do my homework properly before posting the question, cause `strace` on the main process is actually totally silent even when everything is running as it should :p The children are doing stuff though, and `kill -19` on one of the children actually produces the exact results I was hoping for... – Mikk3lRo Jun 03 '15 at 13:59
  • 2
    Glad to hear it. You want me to write that up as an answer, so you can accept it, or just delete the question? – MadHatter Jun 03 '15 at 14:01
  • 1
    I think the question is quite relevant, cause google turned up next to nothing (or rather turned up a heap of irrelevant info on how to kill non-responsive processes)... Go on and post an answer, but I may give it a few days before accepting it, just to see if anyone else has any interesting ideas. – Mikk3lRo Jun 03 '15 at 14:08

1 Answers1

3

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

kill -STOP <pid>

and

kill -CONT <pid>

respectively.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972