Temporarily pause active applications

Every program you’re using on your Mac (obviously) uses some portion of your CPU. And the more you’re asking a given program to do, generally speaking, the more of your CPU it will use. For instance, Safari with one window open isn’t going to load your CPU too heavily. But open seven new windows, put six tabs in each window, and then load up 42 of your favorite web-based Flash games, and you’ll find that Safari is now demanding quite a bit from the CPU. You can see exactly how much by launching Activity Monitor (in Applications > Utilities) and looking at the ‘%CPU’ column next to Safari’s entry in the process list.

Generally, any one program using some portion of your CPU isn’t a problem, as your CPU is seldom taxed to 100% for extended periods of time. But what if you’d like to recapture some of that CPU time for other uses? Consider the example above with 42 Flash games running. In the midst of your gaming-fest, you realize that you need to finish a critical project in iDVD. iDVD works best when you can give it as much of the CPU as possible, especially when rendering and burning a project. However, with 42 Flash games running in Safari, you may not have a lot of spare cycles available.

You could, of course, quit Safari, but that means you’ll have to load Safari, and then find and reload all 42 games when you finish your iDVD project. You’d also lose that new world record score that you were racking up in Burger Dude III, which would be a real shame. So wouldn’t it be great if there were a way to pause Safari, thereby freeing up the CPU, do your iDVD work, and then jump right back into Safari? Obviously, there must be a way to do this, or there wouldn’t be much point to this hint, would there!?

The secret to temporarily stopping any program is to use the Terminal (in Applications > Utilities) and a special mode in the kill program which will simply pause a given application, instead of completely killing it (which is what kill normally does. The first thing you need to do is figure out which program you’d like to pause. To do that, you’ll use two other Unix commands—one called ps (process status) and the other called grep, a search utility. That’s because we need something called the process ID (or pid) of the program we wish to pause, instead of its name.

For purposes of this example, assume it’s Safari you’d like to pause. In the Terminal, type this command:

ps -ax | grep Safari

The ps -ax portion of the command lists all processes, just to make sure you see everything. The pipe symbol (the vertical bar) then passes this list of processes to grep, which searches for the string Safari. By using grep, we won’t have to look at the output for the processes we don’t care about. The output of this command should look something like this:

	6537  ??  S     20:05.19 /Applications/Safari.app ... 0_51642369

8932 p1 S+ 0:00.01 grep Safari
grep SafariSafariKeynoteWord

The process ID is the first number in the output—6537 in this case. To temporarily pause Safari, just type:

kill -STOP 6537

Replace 6537 with the pid number of the program you wish to pause, obviously! There won’t be any output from this command; you’ll just get the Terminal prompt again. And Safari’s open windows will still be open in the background. But if you switch back to the Activity Monitor (or use top in the Terminal), you’ll now see that Safari is using 0.0% of your CPU. And if you try to use the program, you’ll find that it’s completely non-responsive. In fact, a control-click on Safari’s Dock icon will show you the “application not responding” pop-up menu, along with a Force Quit option. But don’t worry, Safari’s just been put into suspended animation. Go off and do whatever it is you needed to do.

When you’re done, switch back to the Terminal, and type:

kill -CONT 6537

This will bring Safari back to life (remember to replace 6537 with the pid you found for your particular program), and ready to go right where you left it. Note that, depending on what pages you may have loaded, you may have some usability issues. For instance, if you pause Safari for 15 minutes while on your bank’s site, and your bank has a 10-minute auto-logout routine, then you may find yourself logged out as soon as the site is able to check the time again.

Generally speaking, however, using kill -STOP is a safe way to temporarily place any application into a state of suspended animation. It’s always a good idea when doing something like this, however, to not leave any unsaved documents open—make sure you save any open documents prior to pausing, just in case something goes wrong.

Shop Tech Products at Amazon