On Wed, Jan 29, 2020 at 03:19:07PM -0500, Roger wrote: > >sigint_handler() { > > trap - INT > > kill -INT $$ > >} > >trap sigint_handler INT > > One thing to note here, I tried inserting the "trap sigint_handler INT" prior > to the loop/for/while statement (or outside of the loop) and the trap doesn't > work as you state it does for yourself. > > I find I have to insert "trap sigint_handler INT" within my loop (for/while) > section of code, for the trap to work. In my eyes or for me, this works as > expected.
That sounds like your loop is inside a subshell. Possibly because you're using it in a pipeline, or possibly other reasons.