[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: signals ignored in a subshell
From: |
Robert Elz |
Subject: |
Re: signals ignored in a subshell |
Date: |
Sun, 05 Apr 2020 01:27:18 +0700 |
Date: Sat, 4 Apr 2020 08:32:57 +0300
From: =?UTF-8?B?T8SfdXo=?= <oguzismailuysal@gmail.com>
Message-ID:
<CAH7i3LqUZcV6shJv6nQoRkLp-zhBgTpWaUPKdzZwVC-W_0e8yw@mail.gmail.com>
| While waiting for read builtin to complete, bash executes signal handlers
| in a subshell where signals are ignored. See below.
|
| $ foo() { trap foo INT; read; }
What that says, is that when you get a SIGINT, call function foo().
When the read is interrupted by the ^C, SIGINT happens, the trap handler
runs, and foo is called again. That sets the trap handler all over again
(no real point, it was still set from before - trap handlers are not local
to function, except possibly the RETURN trap, that one I know nothing about)
and then does read. When you interrupt that one, SIGINT is generated,
the trap handler runs, and foo is called, which sets the trap handler
(yet again) and calls read ...
What were you expecting to happen?
The difference between the various shells depends upon exactly when in the
sequence of things the trap handler actually executes, in some shells it
might not be until after the initial foo function call finishes, in others,
it can happen immediately after the read terminates because of the SIGINT,
while foo is still running.
| Is this a bug or an undocumented feature?
It is bizarre broken application code.
kre
- signals ignored in a subshell, Oğuz, 2020/04/04
- Re: signals ignored in a subshell,
Robert Elz <=
- Re: signals ignored in a subshell, Oğuz, 2020/04/04
- Re: signals ignored in a subshell, Robert Elz, 2020/04/05
- Re: signals ignored in a subshell, Oğuz, 2020/04/05
- Re: signals ignored in a subshell, Chet Ramey, 2020/04/05
- signals ignored in a subshell, Oğuz, 2020/04/06
- Re: signals ignored in a subshell, Oğuz, 2020/04/06
- Re: signals ignored in a subshell, Chet Ramey, 2020/04/06
- Re: signals ignored in a subshell, Robert Elz, 2020/04/06
- Re: signals ignored in a subshell, Robert Elz, 2020/04/06
- Re: signals ignored in a subshell, Chet Ramey, 2020/04/06