Quote:
Originally Posted by leniviy
Honestly, I didn't understand a word.
|
I don't have crystal clarity either but ...
In the simple case, when a bash script is launched from the command prompt and the user presses Ctrl+C, this generates an interrupt signal (SIGINT) which is sent from the terminal to all processes associated with the terminal. The running bash script receives it and exits.
Getting a little more complicated, when the bash script sets up a pipeline, bash creates a child process for each command in the pipeline. Now there's a potential problem; if the bash script exited on receiving SIGINT and its child processes did not then the children would be orphans (sad!) and worse, could turn into zombies (plenty on zombie processes on the 'net).
To avoid this, when bash sets up a pipeline it also configures itself to ignore SIGINT. Which is great for avoiding zombies but does mean, as you have found out, that the script itself can no longer be killed from the terminal using Ctrl+C.
AFAIK that is how it is from the perspective of bash, controlling terminals, processes and SIGINT. Switching to the bash maintainers' perspective, bash is written in C. I guess "
the shell control structure" is actually a C structure (a type of C variable comprising several primitive variable types) which is used to control what bash does with a pipleline (there is probably one such structure per simple command in the pipeline).
Perhaps the maintainer means bash 4.2 will no longer discard any SIGINTs received when it is running a pipeline but will hold them as pending until the pipeline terminates and then action the pending SIGINT(s) in the normal way.
That would be great! It would solve a weakness of shell script as a programming tool dating from the origins of shell script.