bug-bash
[Top][All Lists]
Advanced

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

Execution continuing after SIGINT received


From: Kevin Brodsky
Subject: Execution continuing after SIGINT received
Date: Sat, 5 Aug 2017 00:52:04 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

Hi,

I have run into a rather weird behaviour related to SIGINT, which
doesn't seem to be intended, as it's not consistent with other shells
(and is so unexpected that it took me a while to figure out what was
going wrong in my script!).

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:

$ bash -c '(trap "echo INT; exit 1" INT; sleep 60s); echo after'
^CINT
after
$

Whereas:

$ bash -c '(sleep 60s); echo after'
^C
$

The command doesn't need to be a subshell; for instance, since Python
handles SIGINT by default, execution continues as well:

$ bash -c 'python -c "import time; time.sleep(60)"; echo after'
^CTraceback (most recent call last):
  File "<string>", line 1, in <module>
KeyboardInterrupt
after
$

dash, mksh, zsh don't exhibit this behaviour: in all cases, execution is
aborted. Bash seems to have always behaved like that, at least since 4.0.

Kevin



reply via email to

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