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:
* [How does SIGINT relate to the other termination signals such as SIGTERM, SIGQUIT and SIGKILL?](https://stackoverflow.com/a/4047975/3665178)
>SIGINT
and SIGQUIT
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 for SIGINT
is the same sort of process termination as the default action for SIGTERM
and the unchangeable action for SIGKILL
;
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:
* [signal(7) — Linux manual page](https://www.man7.org/linux/man-pages/man7/signal.7.html)
* [24.2.2 Termination Signals](https://www.gnu.org/software/libc/manual/html_node/Termination-Signals.html)
In many places for these signals are used the _interrupts_ and _terminates_ terms.
Furthermore, from the same answer exists the _@Jonathan Leffler_'s [comment](https://stackoverflow.com/questions/4042201/how-does-sigint-relate-to-the-other-termination-signals-such-as-sigterm-sigquit/4047975#comment4351902_4047975) (extract) as:
>**This is the key point**: SIGINT
and SIGQUIT
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 the kill
command). SIGINT
is less violent than SIGQUIT
; 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
Asked by Manuel Jordan
(2108 rep)
May 17, 2022, 06:23 PM
Last activity: May 18, 2022, 02:52 PM
Last activity: May 18, 2022, 02:52 PM