On 1/13/15 11:37 AM, Guillaume MULLER wrote:
> Hi,
> 
> When I run a for loop in bash, then pausing it with CTL-z, then restarting
> it with fg, the for loop just stops. I don't think this was the behaviour
> until recently, and I don't find it a correct behaviour, according to the
> meaning of the CTL-z "suspend" (https://en.wikipedia.org/wiki/Control-Z).
> Is there any explanation to this behaviour?

SIGTSTP works at the process or job level, not the shell compound command
level.  When you stop the current job with ^Z, the shell has a choice to
make: continue with the loop, or break out of it.  There isn't a handle to
suspend the entire loop's execution, since it doesn't execute in a
separate process.  Bash chooses to break the loop, and has done so for a
very long time (at least back to bash-3.0, which was released ten years
ago, at which point I stopped looking).

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    [email protected]    http://cnswww.cns.cwru.edu/~chet/

Reply via email to