DavidT
DavidT

Reputation: 767

Does Mac terminal killall command quit or force quit?

What exactly do the kill and killall commands do? I realize they terminate an application or process, but do either of them do do it cleanly/safely, like "Quit" in the UI does? Or are they more like "Force Quit"?

Thanks!

(macOS 10.13.4 High Sierra)

Upvotes: 4

Views: 12468

Answers (1)

anothernode
anothernode

Reputation: 5397

The kill command is a UNIX command (macOS is a UNIX variant) that sends signals to processes. There are many different signals that can be sent to processes. The signals have defined names and numeric codes.

If you don't specify a signal, the default will be used, which is the TERM (15) signal. The specification of the TERM signal is designed to give the addressed process a chance to shutdown gracefully, i. e. do some cleaning up before terminating.

Example (all are equivalent):

kill <pid>
kill -15 <pid>
kill -TERM <pid>
kill -s TERM <pid>

A more forceful signal would be the KILL (9) signal, which forces the process to terminate immediately.

Example:

kill -9 <pid>
kill -KILL <pid>
kill -s KILL <pid>

For more information and a complete list of signals, run man kill.

With kill you have to specify the target process by its process ID. The killall command does essentially the same, with the main difference being that it lets you specify target processes by their names. See man killall for details.

Upvotes: 11

Related Questions