You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Mac终端kill、killall命令:是正常退出还是强制退出?功能解析

macOS终端kill、killall命令与UI退出方式的详解

Hey there! Let me break down your questions about macOS terminal kill and killall clearly—since you're on macOS 10.13.4 High Sierra, I’ll make sure this fits your system perfectly.

1. Is killall a normal Quit or Force Quit by default?

By default, killall sends the SIGTERM signal (signal 15) to processes. This is exactly like clicking Quit in the UI: it politely tells the app/program to shut down gracefully, giving it time to save your work, release system resources, or close any open connections properly.

If you add the -9 flag (e.g., killall -9 Safari), you’re switching to the SIGKILL signal. This is the terminal equivalent of Force Quit—the system yanks the process straight out of memory without letting it clean up. Only use this if the app is completely frozen and won’t respond to a normal quit!

2. What’s the difference between kill and killall?

kill

  • Works with unique process IDs (PIDs). You first need to look up the PID of the process you want to terminate (use ps aux or top in the terminal to find these numbers).
  • Defaults to sending SIGTERM (graceful quit)—example: kill 1234 where 1234 is the PID of your target process.
  • You can send other signals too: like kill -HUP 1234 to tell a process to reload its settings, or kill -9 1234 to force it to shut down immediately.

killall

  • Works with process names instead of PIDs. It will kill every running process with that exact name—so killall Finder will shut down all instances of the Finder app (handy when Finder is being glitchy).
  • Also defaults to SIGTERM for a clean shutdown.
  • Just like kill, add -9 to force termination if the process isn’t responding (e.g., killall -9 Slack when Slack is stuck).

3. How do these commands map to the UI’s Quit/Force Quit?

  • Default kill/killall (no -9): Exactly the same as the UI’s Quit. Both send SIGTERM, and well-behaved apps will respond by cleaning up and shutting down safely. This is the preferred way to terminate processes whenever possible.
  • kill -9/killall -9: Identical to the UI’s Force Quit. SIGKILL skips all the process’s normal shutdown logic, so it’s a last resort. Using it can leave temporary files open or cause data loss, so only use it when the process is unresponsive to normal commands.

One quick heads-up: Some processes might ignore SIGTERM (usually if they’re stuck in an infinite loop or frozen). In those cases, the default kill/killall won’t work, and you’ll need to use -9—just like how you’d use Force Quit on a hanging app in the UI.

内容的提问来源于stack exchange,提问作者DavidT

火山引擎 最新活动