I usually have many long-running zsh processes (in spread out over various screen sessions) on my computer, but shells that haven't been used for a while tend to be swapped out. When I switch to such a swapped-out shell and press enter (at an empty prompt) it takes many seconds before the shell responds and a new prompt is displayed (but after that it resumes working perfectly).
To lessen my annoyance I'd like to have a command (e.g. unswap PID
) that I can invoke (from another, already responding shell) to force a shell swap in.
Any ideas on how to achieve this?
P.S. I started off by looking around for a command to ask the system to swap in any process – but I have found no such thing, making me believe that this is not possible. I've here focused my question to zsh
, since this is the case that really interests me, and I'm hoping there might be a solution for that particular case. If you have a more general method that would work for any process (and not just zsh) that would be quite welcome too.
P.P.S. At first I thought of using a trap function inside my shell, which then did some activity (anything) enough to cause the shell to swap in. Having tried this with the WINCH
signal however, I've found that it doesn't work. (Maybe the signal is not delivered to a swapped out process? Are any signals?)
EDIT: In my typical case I have a bunch of zsh
processes running, and then I've left my browser open (with multiple Gmail, Facebook etc tabs) for a bit too long, causing the browser to hoard all of the available RAM and squeezing everything else out into swap. The desktop goes unresponsive for a while, but that clears up kinda quickly. However, when reattaching to a screen session each shell have to be waken up manually (going through them and pressing enter in each shell).
swapoff
andswapon
.... assuming there is enough RAM to do that. – Shove