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    c...@case.edu    http://tiswww.cwru.edu/~chet/

Reply via email to