I know the recommendable way to terminate a foreground process is through the SIGTERM
signal, it because it gives the opportunity to the process itself to clean/release resources. This signal only can be generated/send through a command, it through any of the kill
pkill
killall
commands - until here I am ok. Furthermore it is the default signal for these commands.
Now, I know the SIGINT
signal interrupts a process. Therefore "similar" as terminate.
But I read the following answer (extract) from:
SIGINT
andSIGQUIT
are intended specifically for requests from the terminal: particular input characters can be assigned to generate these signals (depending on the terminal control settings). The default action forSIGINT
is the same sort of process termination as the default action forSIGTERM
and the unchangeable action forSIGKILL
;
Until here according with the answer SIGINT
is triggered by keys combination (ctrl + c) and theoretically SIGINT
does the same than SIGTERM
, it about to: give the program itself the opportunity to clean/release resources.
To be honest after to read many tutorials, I couldn't find and confirm that information explicitly. It for example from:
In many places for these signals are used the interrupts and terminates terms.
Furthermore, from the same answer exists the @Jonathan Leffler's comment (extract) as:
This is the key point:
SIGINT
andSIGQUIT
can be generated from the terminal using single characters, while the program is running. The other signals have to be generated by another program, somehow (eg by thekill
command).SIGINT
is less violent thanSIGQUIT
; the latter produces a core dump
Until here as a possible conclusion: SIGINT
can be triggered through either key combinations or command and SIGTERM
only by command.
Reason of this post: If theoretically SIGINT
does the same than SIGTERM
Question
- When is mandatory send
SIGINT
programmatically?
It appears in kill -l
, so can be use it.
Extra Questions
Again, if theoretically SIGINT
does the same than SIGTERM
- and both can be ignored/blocked/handled
- Why was created
SIGINT
? - Why ctrl + c was not assigned from the beginning to
SIGTERM
?
To be honest I assumed that SIGINT
is not safe because it interrupts the process and therefore would leave some data in a not consistent/integral state
INT
) a program does not necessarily mean "terminating" (TERM
) the program. See e.g. how a shell handles the two signals (ignoresTERM
and letsINT
interrupt a builtin command).SIGINT
is the same sort of process termination as the default action forSIGTERM
"