用 kill 按 PID 终止指定进程

先向指定进程发送正常终止信号,只有当它拒不退出时再强制结束。

macOS进程终端中风险
先运行 kill <PID> 让进程正常退出;如果它仍不退出,再运行 kill -9 <PID> 强制结束。

01命令

命令
$ kill <PID>

02作用说明

kill 默认发送 TERM 信号,正常的应用会捕获这个信号,保存状态、释放文件后再退出。如果进程忽略 TERM 信号仍然存活,可以用 kill -9 发送 SIGKILL,系统内核会立即移除该进程,进程无法拦截或处理这个信号。

03风险

风险中风险
!注意: kill -9 不会给进程任何保存数据或关闭文件的机会,可能留下未保存的修改、临时文件或损坏的数据库。请务必先尝试普通 kill。

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • kill — terminate or signal a process (macOS)
    SS64 · technical · 2026-09-17
    依据: The page shows ending a program with plain kill ("$ kill 1293") and then "Or to really kill it: $ kill -9 1293", and notes that kill defaults to sending TERM.
  • KILL(1) — macOS man page
    KEITH · technical · 2026-09-17
    依据: The man page synopsis includes "kill - signal_number pid ..." (so kill -9 PID is valid) and states the default signal is TERM, which can be caught to allow a clean exit.

最后验证: 2026-09-19 · 分类: 系统与设置

06相关方案