I’m old school and still rocking an old X220 laptop because I didn’t like the new ones. My battery life isn’t as great as I’d like it to be, but it gets worse when some “webapp” (which I’d much rather have as a native GTK+ app) causes Firefox to rev my CPU with their websocket (hi gmail!) poller.
This seems to happen most often on planes or when I’m disconnected from the internet. Since it’s difficult to know which tab is the offending one, and since I might want to keep that tabs state anyway, I decided to write a little shell script to pause and resume misbehaving processes.
After putting it into my
~/bin/ and running
chmod u+x ~/bin/pause-continue.sh on it, you can now:
james@computer:~$ pause-continue.sh firefox Stopping 'firefox'... [press any key to continue] Continuing 'firefox'... james@computer:~$ echo $? # error codes work iirc 0 james@computer:~$
The code is trivially simple, with an added curses hack to make this 13% more fun. It sends a
SIGSTOP signal initially, and then when you press a key it resumes it with
SIGCONT. Here it is the code.
You should obviously substitute in the name of the process that you’d like to pause and resume. If your process breaks because it didn’t deal well with the signals, then you get to keep both pieces!
This should help me on my upcoming travel! I’ll be presenting some of my mgmtconfig work at DevConf.cz, FOSDEM and CfgMgmtCamp.eu! CfgMgmtCamp will also have a short mgmt track (looking forward to seeing Felix present!) and we’ll be around to hack on the 8th during fringe (the day after the official camp) if you’d like help to get your patch merged! I’m looking forward to it!