On 8/4/17 7:52 PM, Kevin Brodsky wrote:

> When Bash receives SIGINT while executing a command, it normally waits
> for the command to complete, and then aborts execution. However, it
> looks like somehow, this is not the case if the command handles SIGINT,
> and execution continues after the command completes. For instance:

The question of what happens when bash receives SIGINT while waiting for a
foreground job to complete has come up many times in the past.

See this for a good discussion of the issue:

https://www.cons.org/cracauer/sigint.html

The basic idea is that the user intends a keyboard-generated SIGINT to go
to the foreground process; that process gets to decide how to handle it;
and bash reacts accordingly.  If the process dies to due SIGINT, bash acts
as if it received the SIGINT; if it does not, bash assumes the process
handled it and effectively ignores it.

Consider a process (emacs is the usual example) that uses SIGINT for its
own purposes as a normal part of operation. If you run that program in a
script, you don't want the shell aborting the script unexpectedly as a
result.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/

Reply via email to