Example use case:
I run Chromium with a couple of tabs open and decide that I don't need to access the application for the next 20 minutes. In order to conserve laptop battery time, I would like to hibernate (freeze) Chromium without having to close the application (re-opening and re-loading all tabs requires time that I would like to save by hibernating it).
You can use the
killall
command to send aSIGSTOP
signal to all processes matching a given name to freeze them and later sendSIGCONT
the same way to thaw them again.First find out the process name using
pgrep -l SEARCH_PATTERN
:Note that it will trim long names, therefore the
r
is missing. But this isn't a problem as you can use Tab completion to enter the process name which will complete it automatically.Then you send the
SIGSTOP
signal to all processes namedchromium-browser
like this:The Chromium window will grey out as if it became unresponsive. Well, it really became unresponsive, so that was to be expected. You can't interact with the window in any way now (except for the menu bar and minimizing etc. which is handled by the window manager and not the application itself). But the events from clicking buttons etc. are still generated and added to the application's event queue, so they will all be processed at once when you thaw the application again!
You thaw the application again by simply running this command that sends the
SIGCONT
signal to the specified processes:Sometimes freezing an application this way can cause it to crash, so make sure important stuff is saved before freezing an application.
In rare cases even the desktop environment/window manger/whatever else might become unresponsive as well. In this case you have to thaw the frozen application through a TTY:
Press Ctrl+Alt+F1 to switch to TTY1. You will be asked to log in, so enter your username and password. Then run the command to thaw the application the same way you would run it through your normal terminal emulator. After that switch back to the desktop (TTY7) using Ctrl+Alt+F7 and you should be fine again.
To suspend, try:
killall -SIGTSTP chromium-browser
If this does not work, try the forceful version:
killall -SIGSTOP chromium-browser
.Either way, to continue use
killall -SIGCONT chromium-browser
. I tried with Firefox and it worked. Do note however, that if you click buttons in Chromium while it is suspended it will execute that stuff once you continue it's execution.You can try the following (in a Terminal):
Then you'll see something like this:
Write down the number 7166 (or whatever number it is) and then do:
That will suspend execution of the process. It won't immediately free the memory used by it, but the memory will be available for other processes if they need it.
Then do
kill -CONT 7166
to work with the program again.Note that you have to change 7166 where appropriate.