Vincent Lefevre <vincent-o...@vinc17.net> wrote, on 11 May 2017:
>
> > What if the shell is not executing a loop? Given
> > 
> > $SHELL -c 'set -m; date ; /bin/sleep 10; date'
> > 
> > all the shells I tested -- execept bash-4.4, which is where we started --
> > kill the shell if the sleep dies due to a SIGINT.  Again, zsh, and mksh
> > as well this time, wait 10 seconds before killing the shell.
>                      ^^^^^^^^^^^^^^^
> 
> More precisely, wait for the sleep command to terminate (these
> 10 seconds corresponds to its argument), i.e. the "sleep" doesn't
> react to Ctrl-C. But a kill -INT kills it. So, it seems that only
> the shell receives the SIGINT from a Ctrl-C, but takes it into
> account only after the current foreground command has terminated.

In this situation, the shell started as $SHELL *is* the foreground
command, which is why it gets the SIGINT.  The process groups it
creates to run date and sleep are background process groups.  This
is because the shell you are typing "$SHELL -c ..." in is the
controlling process for the terminal session, not the one started
as $SHELL.

This is in contrast to the normal case where $SHELL is the controlling
process, in which case the date and sleep commands would be in the
foreground and they would receive SIGINT but the shell would not.

-- 
Geoff Clare <g.cl...@opengroup.org>
The Open Group, Apex Plaza, Forbury Road, Reading, RG1 1AX, England

Reply via email to