Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16097

Re: signals ignored in a subshell

From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: signals ignored in a subshell
Date 2020-04-06 09:24 -0400
Organization ITS, Case Western Reserve University
Message-ID <mailman.246.1586179477.2644.bug-bash@gnu.org> (permalink)
References (3 earlier) <16086.1586068489@jinx.noi.kre.to> <CAH7i3LrwPy9J9+8BPgvT+BGtv39nQJ2H-prxWXu7mHYZ8UjodQ@mail.gmail.com> <45c766ba-4489-bd7b-40c7-32fed37461f9@case.edu> <CAH7i3Lr5zBub6yObXkwV78E0Oyct-bAu2+D2hocpT8NNyBqHLg@mail.gmail.com> <f04bdc73-33d5-f0b8-2358-7e209ef3b269@case.edu>

Show all headers | View raw


On 4/6/20 8:03 AM, Oğuz wrote:

> Okay, you're right, in posix mode the behavior is as expected. However I
> still didn't get why job controls being enabled/disabled changes the way an
> interactive shell handles signals in posix mode. Like
> 
> $ set -o posix
> $
> $ trap 'echo foo' INT
> $
> $ read
> ^Cfoo
> $ sleep 5
> ^C
> $
> $ set +m
> $
> $ read
> ^Cfoo
> $ sleep 5
> ^Cfoo
> 
> Is there a race condition here or does posix mandate this behavior for
> built-in utilities?

When job control is enabled, commands are run in separate process groups,
and those process groups get terminal-generated signals like SIGINT. The
shell never sees them.

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

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: signals ignored in a subshell Chet Ramey <chet.ramey@case.edu> - 2020-04-06 09:24 -0400

csiph-web