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


Groups > gnu.bash.bug > #15848 > unrolled thread

Re: Protect Loop Execution with Traps

Started byRoger <rogerx.oss@gmail.com>
First post2020-01-29 15:19 -0500
Last post2020-01-29 15:19 -0500
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Protect Loop Execution with Traps Roger <rogerx.oss@gmail.com> - 2020-01-29 15:19 -0500

#15848 — Re: Protect Loop Execution with Traps

FromRoger <rogerx.oss@gmail.com>
Date2020-01-29 15:19 -0500
SubjectRe: Protect Loop Execution with Traps
Message-ID<mailman.63.1580329155.2384.bug-bash@gnu.org>
>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.


--
Roger
http://rogerx.sdf.org/

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web