Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
                                 readers
   SIGTERM      15       Term    Termination signal
share|improve this question

marked as duplicate by derobert, Ramesh, Anthon, cuonglm, polym Jul 29 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.

    
1  
Did you read this:unix.stackexchange.com/questions/8916/… –  cuonglm Jul 29 at 15:23
    
They have both interesting details, thanks! –  Volker Siegel Jul 29 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 at 16:59

1 Answer 1

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
1  
@VolkerSiegel Aditya is correct, SIGTERM is the standard –  Patrick Jul 29 at 15:20
2  
Many programs are safe to be sent SIGTERM. –  galegosimpatico Jul 29 at 15:26
1  
@VolkerSiegel You're thinking of SIGKILL. –  Patrick Jul 29 at 15:36
5  
@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 at 15:43
2  
@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 at 15:50

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