[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Protect Loop Execution with Traps
From: |
Greg Wooledge |
Subject: |
Re: Protect Loop Execution with Traps |
Date: |
Wed, 29 Jan 2020 09:33:52 -0500 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
On Wed, Jan 29, 2020 at 01:05:32PM +0700, Robert Elz wrote:
> and (with all respect to Gred) please avoid archaic uses, and use the
> commands as they're currently specified, while "trap - INT" and "trap INT"
> do the same thing, the former is the standard way, similarly for
> "kill -INT ..." and "kill -s INT ..." the latter is the modern version.
I had <https://www.cons.org/cracauer/sigint.html> open at the time,
and got the syntax from there. He actually uses the numeric signal
specifiers ("trap 2"), which I replaced with the modern standard naming
strings; but I didn't replace the legacy single-argument form with
the "-" form. Bash, of course, accepts both.
You're not going to talk me into using "kill -s" any time soon, though.
I don't think I've *ever* seen anyone use that.
> | I'm thinking, put "trap INT; kill -INT $$" inside of it's own function,
Yeah, that's pretty common.
sigint_handler() {
trap - INT
kill -INT $$
}
trap sigint_handler INT
- Protect Loop Execution with Traps, Roger, 2020/01/28
- Re: Protect Loop Execution with Traps, Greg Wooledge, 2020/01/28
- Re: Protect Loop Execution with Traps, Roger, 2020/01/28
- Re: Protect Loop Execution with Traps, Greg Wooledge, 2020/01/28
- Re: Protect Loop Execution with Traps, Roger, 2020/01/28
- Re: Protect Loop Execution with Traps, Robert Elz, 2020/01/29
- Re: Protect Loop Execution with Traps,
Greg Wooledge <=
- Re: Protect Loop Execution with Traps, Roger, 2020/01/29
- Re: Protect Loop Execution with Traps, Roger, 2020/01/29
- Re: Protect Loop Execution with Traps, Greg Wooledge, 2020/01/29