mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-12 13:10:45 +02:00
minor documentation update on SIGINT handling
This commit is contained in:
@@ -3549,6 +3549,37 @@ which a trap has been set will cause the @code{wait} builtin to return
|
||||
immediately with an exit status greater than 128, immediately after
|
||||
which the trap is executed.
|
||||
|
||||
When job control is not enabled, and Bash is waiting for a foreground
|
||||
command to complete, the shell receives keyboard-generated signals
|
||||
such as @code{SIGINT} (usually generated by @samp{^C}) that users
|
||||
commonly intend to send to that command.
|
||||
This happens because the shell and the command are in the same process
|
||||
group as the terminal, and @samp{^C} sends @code{SIGINT} to all processes
|
||||
in that process group.
|
||||
See @ref{Job Control}, for a more in-depth discussion of process groups.
|
||||
|
||||
When Bash is running without job control enabled and receives @code{SIGINT}
|
||||
while waiting for a foreground command, it waits until that foreground
|
||||
command terminates and then decides what to do about the @code{SIGINT}:
|
||||
|
||||
@enumerate
|
||||
@item
|
||||
If the command terminates due to the @code{SIGINT}, Bash concludes
|
||||
that the user meant to end the entire script, and acts on the
|
||||
@code{SIGINT} (e.g., by running a @code{SIGINT} trap or exiting itself);
|
||||
|
||||
@item
|
||||
If the pipeline does not terminate due to @code{SIGINT}, the program
|
||||
handled the @code{SIGINT} itself and did not treat it as a fatal signal.
|
||||
In that case, Bash does not treat @code{SIGINT} as a fatal signal,
|
||||
either, instead assuming that the @code{SIGINT} was used as part of the
|
||||
program's normal operation (e.g., @command{emacs} uses it to abort editing
|
||||
commands) or deliberately discarded. However, Bash will run any
|
||||
trap set on @code{SIGINT}, as it does with any other trapped signal it
|
||||
receives while it is waiting for the foreground command to
|
||||
complete, for compatibility.
|
||||
@end enumerate
|
||||
|
||||
@node Shell Scripts
|
||||
@section Shell Scripts
|
||||
@cindex shell script
|
||||
|
||||
Reference in New Issue
Block a user