How to kill a process in MacOS?

Viewed 182625

I tried kill -9 698 but the process did not die.

$ ps -ef | grep chromium
  502   698   811   0   0:01.24 ??         0:07.28 /Users/lucius/chromium/src/xcodebuild/Debug/Chromium.app/Contents/MacOS/Chromium
  502   854   732   0   0:00.00 ttys001    0:00.00 grep chromium
$ kill -9 698


$ ps -ef | grep chromium
  502   698   811   0   0:01.24 ??         0:07.28 /Users/lucius/chromium/src/xcodebuild/Debug/Chromium.app/Contents/MacOS/Chromium
  502   854   732   0   0:00.00 ttys001    0:00.00 grep chromium
10 Answers

If you're trying to kill -9 it, you have the correct PID, and nothing happens, then you don't have permissions to kill the process.

Solution:

$ sudo kill -9 PID

Okay, sure enough Mac OS/X does give an error message for this case:

$ kill -9 196
-bash: kill: (196) - Operation not permitted

So, if you're not getting an error message, you somehow aren't getting the right PID.

If you know the process name you can use:

killall Dock

If you don't you can open Activity Monitor and find it.

If kill -9 isn't working, then neither will killall (or even killall -9 which would be more "intense"). Apparently the chromium process is stuck in a non-interruptible system call (i.e., in the kernel, not in userland) -- didn't think MacOSX had any of those left, but I guess there's always one more:-(. If that process has a controlling terminal you can probably background it and kill it while backgrounded; otherwise (or if the intense killing doesn't work even once the process is bakcgrounded) I'm out of ideas and I'm thinking you might have to reboot:-(.

Given the path to your program, I assume you're currently running this under Xcode, and are probably at a debug breakpoint. Processes cannot be killed in this state because of the underlying implementation of breakpoints.

The first step would be to go to your Xcode process and stop debugging. If for some strange reason you have lost access to Xcode (perhaps Xcode has lost access to its gdb sub-process), then the solution is to kill the gdb process. More generally, the solution here is to kill the parent process. In your case this is PID 811 (the third column).

There is no need to use -9 in this case.

Do you can list the process using a port with command lsof, for example:

lsof -i tcp:PORT_NUMBER_HERE

Replace the word PORT_NUMBER_HERE to the port number that you are using, then a the process running on the port will be listed. Then you have just to kill the process ID founded like this:

kill PID_NUMBER

Where PID_NUMBER is the process ID running on the port.

I recently faced similar issue where the atom editor will not close. Neither was responding. Kill / kill -9 / force exit from Activity Monitor - didn't work. Finally had to restart my mac to close the app.

in the spotlight, search for Activity Monitor. You can force fully remove any application from here.

enter image description here

Related