Suspending and resuming a process on OS X

1&1 Web Hosting
A MacBook Pro laptop with OS X Yosemite (10.10.5) I've been using today had been performing poorly. When I checked on CPU and memory usage, I found Firefox 38.7.0 was responsible for most of the memory usage and was consuming an excessive amount of CPU cycles. The Activity Monitor application, which is found in Applications/Utilities, showed that Firefox was consuming about 1/2 of the 16 GB of Random Access Memory (RAM) on the system.

Activity Monitor - Firefox memory 
usage

And when I checked CPU usage and ordered the processes displayed by CPU usage percentage by clicking on the % CPU column header, I saw that Firefox was using about 100% of the CPU cycles. Firefox eventually got to the point where the Activity Monitor showed a status of "Not Responding" next to its process name.

Activity Monitor - Firefox CPU
usage

I didn't want to kill the Firefox process, which I could have done by double-clicking on the Firefox entry in Activity Monitor and then clicking on the Quit button in the process details window, but I needed to make the system more responsive so I could complete some pressing tasks. So I decided to suspend the process temporarily so that it was no longer taxing the system with the number of CPU cycles it was consuming.

You can suspend/pause a process, so that it can be resumed later, from a command line interface, i.e., the Bash shell prompt you can obtain by running the Terminal application found in Applications/Utilities, using the kill command with the -STOP option. The format for the command is kill -STOP PID, where PID is the process identifier (PID) for the process. You can obtain the PID for a process from the PID column in Activity Monitor or from the command line by using ps aux followed by a grep command to filter the output of the ps command by the relevant process name, which in this case is "firefox":

$ ps aux | grep firefox | grep -v grep
jasmith1          509 100.5 23.0 13283344 3859620   ??  R     5May16 8271:32.53 
/Applications/Firefox.app/Contents/MacOS/firefox -psn_0_45067

The PID is shown in the second column of the output; the CPU utilization is shown as a percentage in the third column. Since the PID was 509 in this case, I could stop Firefox temporarily with the command below:

$ kill -STOP 509
$

The CPU usage displayed by Activity Monitor then declined considerably and Firefox no longer appeared at the top of the list of processes when I had them ordered by CPU utilization. But, when I sorted by process name by clicking on the Process Name column header, I could see that Activity Monitor still had it listed, but with 0 percent CPU usage now.

Activity Monitor - Firefox not
running

The memory utilization remained similar to what it had been before when the program was running, however.

I could still see it listed when I issued the ps aux command, also, but the CPU usage shown in the third column was now at 0.0.

$ ps aux | grep firefox | grep -v grep
jasmith1          509   0.0 22.9 13316048 3848612   ??  T     5May16 8298:16.00 

I could resume the process functioning using the -CONT parameter for the kill command in place of the -STOP I had used previously. I.e., I could start it again with the command below:

$ kill -CONT 509
$

Of course, that resulted in the process returning to its excessive CPU usage.

 

TechRabbit ad 300x250 newegg.com

Justdeals Daily Electronics Deals1x1 px