Originally Posted by mircan
I understand that you mean that it is the shell that sends the signal to the script, am I right?
AFAIK the kernel handles the terminal (screen and keyboard) according to how the terminal is configured. By default this configuration includes setting Ctrl+C to generate the intr signal (interrupt, also known as SIGINT) as shown by
Thus, when Ctrl+C is pressed on the keyboard, the kernel sends a SIGINT to all processes that have this particular terminal as their "controlling terminal" (the "process group"?), including the shell and its child processes and their child processes ... .
When a shell is a running a child process it disables SIGINT as explained here
until the child process terminates. Thus, when you are running a process from a shell, the process is sent SIGINT and acts on it according to how it is configured; if and when it exits the shell then processes SIGINT according to how it is configured.