bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SIGINT kills interactive shell from dot script


From: Chet Ramey
Subject: Re: SIGINT kills interactive shell from dot script
Date: Wed, 9 Nov 2016 09:11:47 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

On 11/8/16 1:50 PM, Martijn Dekker wrote:

> Works as expected: The 'trap' command is on the same command line as the
> loop. The signal is properly ignored, the trap is properly executed
> repeatedly on pressing Ctrl+C.
> 
> $ trap 'echo INT' INT; i=0; while [ $((i+=1)) -lt 1000000 ]; do :; done
> ^CINT
> ^CINT
> ^CINT
> $ echo $? $i
> 0 1000000
> 
> Buggy behaviour: The 'trap' command is on a separate command line.
> The signal is not ignored. The trap is executed once on Ctrl+C and the
> loop is interrupted.
> 
> $ trap 'echo INT' INT
> $ i=0; while [ $((i+=1)) -lt 1000000 ]; do :; done
> ^CINT

Thanks for the report.  This is actually something I had flagged to look
at after bash-4.4 was released:

      /* XXX - why do we set this every time through the loop?  And why do
         it if SIGINT is trapped in an interactive shell? */

It looks like not that many people trap SIGINT in an interactive shell.

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]