Kill -INT vs kill -TERM

What is the difference between a SIGINT signal and a SIGTERM signal? I know that SIGINT equivalent to pressing Ctrl + C on the keyboard, but what is SIGTERM for? If I wanted to stop some background process gracefully, which one should I use?

+6
source share
4 answers

The only difference in the answer depends on the developer. If the developer wants the application to respond to SIGTERM differently than to SIGINT , then other handlers will be registered. If you want to terminate the background process gracefully, you usually send SIGTERM . If you are developing an application, you must respond to SIGTERM by exiting gracefully. SIGINT often handled the same, but not always. For example, it is often convenient to respond to SIGINT by reporting a status or partial calculation. This makes it easier for the user to run the application on the terminal to get partial results, but itโ€™s a little harder to shut down the program, since it usually requires the user to open another shell and send SIGTERM via kill . In other words, it depends on the application, but the agreement is to respond to SIGTERM , gracefully shutting down, the default action for both signals ends, and most applications respond to SIGINT , stopping gracefully.

+10
source

If I would like to gracefully stop any background process, which one should I use?

The list of unix signals dates back to the time when computers had serial terminals and modems in which the concept of a control terminal appears. When the modem drops the carrier, the line is suspended.

SIGHUP (1) therefore indicates a loss of connection, causing programs to exit or restart. For daemons such as syslogd and sshd, processes without a terminal connection that should continue to run, SIGHUP is usually a signal that is used to restart or reset.

SIGINT (2) and SIGQUIT (3) literally โ€œbreakโ€ or โ€œendโ€, โ€œfrom the keyboardโ€, giving the user immediate control if the program is accelerated. With a terminal with a physical character, this will be the only way to stop the program!

SIGTERM (15) is not related to terminal processing and can only be sent from another process. This will be a normal signal to send to the background process.

+6
source

SIGINT is the program interrupt signal that will be sent when the user presses Ctrl + C. SIGTERM is the termination signal that will be sent to the process to request the completion of the process, but it can be caught or ignored by this particular process.

0
source

Here is a link that describes the difference, as well as other important things. http://programmergamer.blogspot.in/2013/05/clarification-on-sigint-sigterm-sigkill.html

0
source

Source: https://habr.com/ru/post/947850/


All Articles