r/ProgrammerTIL • u/markasoftware • Apr 07 '22
Other Language [Linux] TIL that you can pause and resume processes
By sending the SIGSTOP and SIGCONT signals, eg:
pkill -SIGSTOP firefox # suspend firefox
pkill -SIGCONT firefox # resume firefox
Does not require application-level support!
It seems to work pretty well even for large applications such as web browsers. Excellent when you want to conserve battery or other resources without throwing away application state.
151
Upvotes
14
u/Eroviaa Apr 07 '22
With
criuyou can do even more, like snapshotting a process, moving it to a different computer and restoring it.It's a tool you won't need 99.99% of the time, but when you need it, you are so glad it exists.
16
u/real_kerim Apr 07 '22
Yeah, that's really cool! There's actually some more really useful signals. E.g. you can also read the dd process' progress by sending it a -USR1 signal, though I heard that that's the old school way of doing things by now.
11
u/virtulis Apr 07 '22
I use this to make misbehaving Unity games not eat up the cpu/gpu while minimized.
13
u/heeen Apr 07 '22
isn't that the same as ctrl-z and fg in a terminal?
6
u/ponytoaster Apr 07 '22
You can also do this in windows using inbuilt ResMon. Suspend and resume processes from there. Although I've only done it a handful of times in my entire existence.
2
u/alphabytes Apr 07 '22
dang thats awesome.
0
u/[deleted] Apr 08 '22
[deleted] — view deleted comment