Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

If I want to kill a process as careful and politely as possible,
which signals should I use in a kill command, in which order?

I would like to give the programm any kind of time to clean up, if it likes to, so just sending a SIGTERM will be to harsh, I think?

I'll use SIGKILL ("-9") last, that's clear.

But which to start? SIGHUP? Which signals are just a waste of time?

The relevant signals for reference, from

man 7 signal

  Signal     Value     Action   Comment
   SIGHUP        1       Term    Hangup detected on controlling terminal
                                 or death of controlling process
   SIGINT        2       Term    Interrupt from keyboard
   SIGQUIT       3       Core    Quit from keyboard
   SIGKILL       9       Term    Kill signal
   SIGPIPE      13       Term    Broken pipe: write to pipe with no
   SIGTERM      15       Term    Termination signal
share|improve this question

marked as duplicate by derobert, Ramesh, Anthon, cuonglm, polym Jul 29 '14 at 16:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Did you read this:unix.stackexchange.com/questions/8916/… – cuonglm Jul 29 '14 at 15:23
They have both interesting details, thanks! – Volker Siegel Jul 29 '14 at 15:44
This has a partial answer regarding the signal order (contradicting the order in the other references): Ignacio Vazquez-Abrams on When you try to terminate a process for good, which option for “kill” should you use? – Volker Siegel Jul 29 '14 at 16:59

SIGTERM is the way to go in my opinion. It has works in most of the cases. The ones in which this will not work, you'll have to do a SIGKILL anyway. SIGTERM gives process enough opportunity to release all the resources it has to and shut down cleanly.

share|improve this answer
@VolkerSiegel Aditya is correct, SIGTERM is the standard – Patrick Jul 29 '14 at 15:20
Many programs are safe to be sent SIGTERM. – uprego Jul 29 '14 at 15:26
@VolkerSiegel You're thinking of SIGKILL. – Patrick Jul 29 '14 at 15:36
@VolkerSiegel You've got 3 different people telling you to use SIGTERM. If you're such an expert on signals, why did you even ask the question? – Patrick Jul 29 '14 at 15:43
@VolkerSiegel if a program isn't coded to catch SIGTERM and handle it "friendly" then chances are it isn't going to handle SIGINT friendly either. If a program is capable of a "friendly" termination from a signal, SIGTERM is almost assuredly going to be handled. Think of it this way: If you were writing a program that you wanted clean, friendly shutdowns, would you catch SIGINT but ignore SIGTERM? That makes no sense. – casey Jul 29 '14 at 15:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.