I tried kill -9 698
but the process did not die.
我试着杀死- 9698,但过程并没有结束。
$ 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
7 个解决方案
#1
86
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.
如果您试图杀死-9,那么您有正确的PID,并且什么也没有发生,那么您就没有权限杀死进程。
Solution:
解决方案:
$ sudo kill -9 PID
Okay, sure enough Mac OS/X does give an error message for this case:
好的,确实,Mac OS/X在这个例子中给出了错误信息:
$ 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.
如果你没有得到错误消息,你就没有得到正确的PID。
#2
5
If you know the process name you can use:
如果您知道流程名称,您可以使用:
killall Dock
If you don't you can open Activity Monitor and find it.
如果你不这样做,你可以打开活动监视器并找到它。
#3
4
Some cases you might want to kill all the process running in a specific port. For example, if I am running a node app on 3000 port and I want to kill that and start a new one; then I found this command useful.
在某些情况下,您可能希望终止在特定端口上运行的所有进程。例如,如果我在3000端口上运行一个节点应用程序,我想终止它并启动一个新的;然后我发现这个命令很有用。
Find the process IDs running on TCP port 3000 and kill it
查找在TCP端口3000上运行的进程id并将其杀死
kill -9 `lsof -i TCP:3000 | awk '/LISTEN/{print $2}'`
#4
2
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:-(.
如果“杀死-9”不起作用,那么“杀死-9”也不会起作用(甚至“杀死-9”更“强烈”)。很明显,chromium进程被卡在了一个不可中断的系统调用中(即。在内核中,而不是在userland中)——不认为MacOSX中有任何一个,但我想总会有一个:-(。如果这个进程有一个控制终端,你可以在后台设置它并杀死它;否则(或者,即使是在巴科斯基的过程中,强烈的杀戮也不起作用)我没有想法了,我想你可能需要重新启动:
#5
2
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.
给定程序的路径,我假设您目前正在Xcode下运行这个程序,并且可能处于调试断点位置。由于断点的底层实现,进程不能在这种状态下被终止。
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).
第一步是进入您的Xcode流程并停止调试。如果由于某种奇怪的原因,您失去了对Xcode的访问(也许Xcode失去了对其gdb子进程的访问),那么解决方案就是终止gdb进程。更一般地说,这里的解决方案是终止父进程。在您的例子中,这是PID 811(第三列)。
There is no need to use -9 in this case.
在这种情况下不需要使用-9。
#6
2
I just now searched for this as I'm in 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. It worked cleanly for me, in the absence of the hyphen '-' character. I hope it helps!
我刚刚搜索了这个,因为我有类似的情况,我没有杀死- 9698,我尝试了sudo杀死428,428是我要杀死的过程的pid。在没有连字符“-”字符的情况下,它对我来说工作得很干净。我希望它可以帮助!
#7
1
I have experienced that if kill -9 PID
doesn't work and you own the process, you can use kill -s kill PID
which is kind of surprising as the man page says you can kill -signal_number PID
.
我有过这样的经历如果杀死-9 PID不起作用并且你拥有这个过程,你可以使用杀死-s杀死PID这有点让人惊讶就像手册里说的那样你可以杀死-signal_number PID。
#1
86
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.
如果您试图杀死-9,那么您有正确的PID,并且什么也没有发生,那么您就没有权限杀死进程。
Solution:
解决方案:
$ sudo kill -9 PID
Okay, sure enough Mac OS/X does give an error message for this case:
好的,确实,Mac OS/X在这个例子中给出了错误信息:
$ 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.
如果你没有得到错误消息,你就没有得到正确的PID。
#2
5
If you know the process name you can use:
如果您知道流程名称,您可以使用:
killall Dock
If you don't you can open Activity Monitor and find it.
如果你不这样做,你可以打开活动监视器并找到它。
#3
4
Some cases you might want to kill all the process running in a specific port. For example, if I am running a node app on 3000 port and I want to kill that and start a new one; then I found this command useful.
在某些情况下,您可能希望终止在特定端口上运行的所有进程。例如,如果我在3000端口上运行一个节点应用程序,我想终止它并启动一个新的;然后我发现这个命令很有用。
Find the process IDs running on TCP port 3000 and kill it
查找在TCP端口3000上运行的进程id并将其杀死
kill -9 `lsof -i TCP:3000 | awk '/LISTEN/{print $2}'`
#4
2
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:-(.
如果“杀死-9”不起作用,那么“杀死-9”也不会起作用(甚至“杀死-9”更“强烈”)。很明显,chromium进程被卡在了一个不可中断的系统调用中(即。在内核中,而不是在userland中)——不认为MacOSX中有任何一个,但我想总会有一个:-(。如果这个进程有一个控制终端,你可以在后台设置它并杀死它;否则(或者,即使是在巴科斯基的过程中,强烈的杀戮也不起作用)我没有想法了,我想你可能需要重新启动:
#5
2
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.
给定程序的路径,我假设您目前正在Xcode下运行这个程序,并且可能处于调试断点位置。由于断点的底层实现,进程不能在这种状态下被终止。
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).
第一步是进入您的Xcode流程并停止调试。如果由于某种奇怪的原因,您失去了对Xcode的访问(也许Xcode失去了对其gdb子进程的访问),那么解决方案就是终止gdb进程。更一般地说,这里的解决方案是终止父进程。在您的例子中,这是PID 811(第三列)。
There is no need to use -9 in this case.
在这种情况下不需要使用-9。
#6
2
I just now searched for this as I'm in 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. It worked cleanly for me, in the absence of the hyphen '-' character. I hope it helps!
我刚刚搜索了这个,因为我有类似的情况,我没有杀死- 9698,我尝试了sudo杀死428,428是我要杀死的过程的pid。在没有连字符“-”字符的情况下,它对我来说工作得很干净。我希望它可以帮助!
#7
1
I have experienced that if kill -9 PID
doesn't work and you own the process, you can use kill -s kill PID
which is kind of surprising as the man page says you can kill -signal_number PID
.
我有过这样的经历如果杀死-9 PID不起作用并且你拥有这个过程,你可以使用杀死-s杀死PID这有点让人惊讶就像手册里说的那样你可以杀死-signal_number PID。