Killing OS X Applications, the easy way. - Gavablog

Killing OS X Applications, the easy way.

Let’s face it: applications aren’t perfect. And OS X is by no means the greatest operating system ever written. When applications freeze, they can be killed. But sometimes they freeze hard enough that even right clicking on the dock icon and selecting “Force Quit” sometimes doesn’t cut it. While playing around with terminal commands the other day, I found a neat little way to kill applications from the terminal.

OS X applications are hidden from the user. Entering ‘ps’ on a terminal doesn’t produce the output you’d expect from a Linux/Unix machine. Thus, they’re a bit trickier to kill. Here, I’ve used ‘kill -STOP [pid]‘ to freeze up Mail.app for demonstration.

ooooh noessss

ooooh noessss

Unfortunately, OS X doesn’t capture the cursor, thus you can’t really tell it’s frozen. But trust me, it’s completely unresponsive.

So, how to fix it? First, you pull up a terminal.

See? Term!

See? Term!

Then you enter some stuff into the terminal.

ps -A | grep Mail

ps -A | grep 'Mail'

The -A argument to ps will prompt ps to output information on processes that you don’t control (root, system) and processes without terminals. The | will push the results to grep, which receives the argument ‘Mail’, prompting grep to search through the list of processes produced by ps for processes with the word ‘Mail’ associated with them. The command will produce this output:

Yay results!

Yay results!

The number farthest left is what you’re looking for. In this case it’s “51845″. A second terminal command, kill, will be able to stop this resource hog!

kill it with kill -9!

kill it with kill -9!

‘kill -9′ is a sort of force kill. Give it a process id (pid) and it’ll zap it from the face of the earth. Remember the number from the previous picture? Well, we’ll be needing it here. Enter ‘kill -9 (number without parentheses)’. Tada! No more unreasonable process. Enter ‘ps -A | grep ‘Mail’ again, to find just the single entry! Yayyyy.

Terminal commands are neat little insights into how Unix based operating systems behave the way they do. Replacing any instance of ‘Mail’ with ‘Name of not behaving application’ will also work. Good luck!

1 Comment so far

  1. jwNo Gravatar on October 8th, 2009

Leave a Reply