Linux: close a program with command line (not kill it)
By default, the kill command will send SIGTERM
(termination signal) to the running process. Unlike SIGKILL
, which will forcibly kill the process with no chance to respond, the SIGTERM
signal can be intercepted by the process, allowing it to terminate gracefully. Whether or not it actually does terminate gracefully is entirely dependent on the process itself; it can just as easily kill itself or ignore the signal entirely.
You can ensure that you are sending SIGTERM
instead of some other signal by making it explicit on the command line thus:
kill -s TERM <pid>
Note that when using pkill
rather than kill
, to specify TERM the syntax is:
pkill -TERM <process-name>
pkill
is just like kill, but you can use the process name rather than the id. man pkill