Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #15802
| From | Martijn Dekker <martijn@inlv.org> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | trap: interactive bash exits on resending SIGINT twice |
| Date | 2020-01-14 17:24 +0100 |
| Message-ID | <mailman.2542.1579019061.1979.bug-bash@gnu.org> (permalink) |
| References | <9e22237a-78bf-c0bf-efcf-7f536cbed5ea@inlv.org> |
Setting the following trap makes an interactive bash (any version) exit on issuing SIGINT: trap 'trap "true" INT; kill -s INT $$; trap - INT; kill -s INT $$' INT # ^^^^^^^^^^^^^^^ eat signal ^^^^^^^^^^ unset trap After setting that trap, pressing Ctrl+C, or otherwise causing SIGINT to be sent, causes an interactive bash to exit. Expected behaviour: no exit. Confirmed on macOS and Debian. Ignoring the signal instead of merely eating it seems to be an effective workaround on more recent bash versions: trap 'trap "" INT; kill -s INT $$; trap - INT; kill -s INT $$' INT This avoids an interactive shell exiting on SIGINT on bash 4.4 and 5.0, but not 4.3 or earlier. - M. -- modernish -- harness the shell https://github.com/modernish/modernish
Back to gnu.bash.bug | Previous | Next | Find similar
trap: interactive bash exits on resending SIGINT twice Martijn Dekker <martijn@inlv.org> - 2020-01-14 17:24 +0100
csiph-web