8

I would like to pause/freeze a process in time; how can I do that?

Not duplicate because kill -STOP <PID> has caused applications to crash when I've used it.

4
  • You want to pause and freeze, I don't see the link to duplicating the process and how would you do that with kill? Did something get accidentally deleted when editing your post?
    – Anthon
    Mar 18, 2016 at 20:42
  • 2
    STOP is the canonical signal for this. What does "seems to be hit or miss" mean?
    – thrig
    Mar 18, 2016 at 20:47
  • 3
    kill -STOP is the answer. If it causes some application to crash, that's a bug in the application, and we can't help you if you don't tell us what the application is (but the author of the application would be able to help you more). Mar 18, 2016 at 22:18
  • 2
    Press Ctrl+Z if it's your foreground jobs (Equivalent to killing the foreground process group with SIGTSTP. SIGSTOP suspends unconditionally. SIGTSTP gives the process a chance to react.) Mar 18, 2016 at 22:19

1 Answer 1

16

You can use the STOP signal to pause a process, and CONT to resume its execution:

kill -STOP ${PID}
kill -CONT ${PID}
4
  • What is if the process to be frozen is not a mere trivial program, but one that interacts with lots of other processes? Will this form of freezing a process work then also? Nov 19, 2019 at 10:21
  • @humanityANDpeace kill -STOP will pause a process regardless of what it’s doing or how complex it is; like -KILL, it can’t be overridden. Nov 19, 2019 at 10:24
  • I want to pause the whole that is gnome-session a process that interdepents of/to/with other processes, I would expect that a pause->unpause would corrupt that intricate interplay of IPCs going on and hence be impractical, correct? Nov 19, 2019 at 10:27
  • @humanityANDpeace yes, it would at least introduce delays (and presumably timeouts). I wouldn’t try it ;-). Nov 19, 2019 at 10:31