You need to close the applications properly when you interrupt your application with signals such as
SIGTERM
or
SIGINT
. SIGTERM
is one of the POSIX signals that sends a signal to a process to end it. Signals are asynchronous and are vulnerable to race conditions.
SIGTERM
: When you execute thekill
command with its defaults in a Unix system, you are basically calling aSIGTERM
signal to the denoted process. These signals should be handled properly so your application can release the resources or close database connections and flush the messages properly.SIGINT
: This signal can be caught by the application just likeSIGTERM
as well. The user usually calls it with Ctrl + C.SIGKILL
: This is the signal that is called with akill -9
command. However, this signal cannot be caught by an application, so there is nothing much we could do about it.
SIGINT
could be caught in languages that support exception handling by throwing the proper exception such as KeyboardInterrupt...