How to kill a process on macOS?

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 
+54
macos
May 24 '09 at 4:32 a.m.
source share
8 answers

If you try to kill -9, you have the correct PID, and nothing happens, then you have no right to kill the process.

Decision:

 $ sudo kill -9 PID 



Well, of course, Mac OS / X gives an error message for this case:

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

So, if you do not receive the error message, you somehow do not receive the correct PID.

+100
May 24 '09 at 4:38
source share
— -

In some cases, you can kill the entire process running on a specific port. For example, if I run a node application on 3000 ports and I want to kill it and launch a new one; then I found this command useful.

Find the process IDs running on TCP host 3000 and kill it

 kill -9 `lsof -i TCP:3000 | awk '/LISTEN/{print $2}'` 
+7
Apr 28 '16 at 2:35 pm
source share

If you know the name of the process you can use:

 killall Dock 

If you do not, you can open Activity Monitor and find it.

+6
May 24 '09 at 4:35
source share

If kill -9 does not work, then there will not be killall (or even killall -9 , which will be more "intense"). Apparently, the chrome process gets stuck in a non-stop system call (i.e., in the kernel, not in userland) - I did not think that MacOSX had any of them, but I think there is always one more :-( .the process has a control terminal, you can probably compose it and kill it during the wallpaper, otherwise (or if intensive killing does not work even after the process is based on bakcgrounded) I have no ideas and I think that you have to reboot: -. (

+2
May 24 '09 at 4:40 a.m.
source share

Given the path to your program, I assume that you are currently running this under Xcode and are probably at the debugging breakpoint. Processes cannot be killed in this state due to the underlying implementation of breakpoints.

The first step is to switch to the Xcode process and stop debugging. If for some strange reason you lose access to Xcode (maybe Xcode has lost access to the gdb subprocess), then the solution should kill the gdb process. More generally, the solution here is to kill the parent process. In your case, this is PID 811 (third column).

In this case, there is no need to use -9.

+2
May 24 '09 at 16:42
source share

I just searched for this as I enter a similar situation and instead of kill -9 698 I tried sudo kill 428 , where 428 was the pid of the process I'm trying to kill. This worked purely for me, in the absence of a hyphen. Hope this helps!

+2
Aug 27 '14 at 2:58
source share

I experienced that if kill -9 PID does not work and you own the process, you can use kill -s kill PID , which is surprising since on the kill -signal_number PID page you can kill -signal_number PID .

+1
May 8 '13 at 22:31
source share

I recently encountered a similar problem when the atom editor is not closed. None answered. Kill / kill -9 / force exit Activity Monitor - did not work. Finally I had to restart my Mac to close the application.

0
May 02 '19 at 2:21
source share



All Articles