[Top][All Lists]

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

Re: SIGINT kills interactive shell from dot script

From: Martijn Dekker
Subject: Re: SIGINT kills interactive shell from dot script
Date: Mon, 7 Nov 2016 12:54:16 +0000
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

Op 06-11-16 om 16:52 schreef Chet Ramey:
> On 11/6/16 4:08 AM, Martijn Dekker wrote:
>> An interactive bash is killed by SIGINT after a command to unset any
>> trap for SIGINT.
>> $ cat >/tmp/dotscript <<EOF
>> trap
>> trap - INT
>> kill -s INT "$$"
>> EOF
>> $ . /tmp/dotscript
>> (no output of 'trap')
>> (interactive shell exits)
> You're on a roll finding long-lived bugs this week.

I've been finding various bugs in various shells for some time now:
(and those are just the ones I decided were non-fatal for the purposes
of the library).
Developing a cross-platform POSIX shell library tends to expose strange
and obscure stuff. I've catalogued most of the bugs found with IDs and
corresponding bug tests, so scripts can easily check for a bug and work
around it. Most of them were fixed for new releases after I reported
them (but not the ksh93 ones as ksh93 development appears to be dormant).

Unfortunately it would be hard to script a proper bug test for the
particular bug reported in this thread, because it only occurs on
interactive shells. So, for modernish stack-based traps (which must
"unignore" and reissue the signal after executing stack traps if no
plain-old-POSIX trap was set, which is how I found this bug) I've had to
resort to checking for BASH_VERSION and handling SIGINT specially for
interactive bash.

But it's really helped that bash turns out to have another unique
behaviour: apparently, bash refuses to ignore SIGINT on interactive
shells. So, for interactive bash, the workaround is simply to avoid
using "trap - INT" to unignore the signal.


- M.

reply via email to

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