aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-04-03 08:33:14 +0100
committerRon Yorston <rmy@pobox.com>2023-04-03 08:33:14 +0100
commit64c8f5f3d0bbfcaf3b88aa97a23d90c14326b79e (patch)
tree878917ac4dfd0d271494a1b5436db918b0a0ed88 /libbb
parent1b2ee3667543b2588446dba6655720eb929bfe03 (diff)
downloadbusybox-w32-64c8f5f3d0bbfcaf3b88aa97a23d90c14326b79e.tar.gz
busybox-w32-64c8f5f3d0bbfcaf3b88aa97a23d90c14326b79e.tar.bz2
busybox-w32-64c8f5f3d0bbfcaf3b88aa97a23d90c14326b79e.zip
ash: add support for INT trap
The trap builtin now handles INT. As before, other signals (from a limited list) are accepted but their traps don't have any effect. There's some variability in how shells handle traps. This patch upholds that proud tradition. Various changes are needed to make this work: - Line editing has a new flag to ignore Ctrl-C. - If INT is being trapped or ignored don't call raise_interrupt(). - A minimal implementation of dotrap() is provided. - Call dotrap() when the read builtin or line input detect Ctrl-C. - Adjust Ctrl-C detection when the INT trap is changed. - Set may_have_traps when an INT trap is set. Costs 368-448 bytes. (GitHub issue #303)
Diffstat (limited to 'libbb')
-rw-r--r--libbb/lineedit.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 9220ddeb3..45d4c33f5 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -3030,6 +3030,10 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman
3030 && ic_raw == initial_settings.c_cc[VINTR] 3030 && ic_raw == initial_settings.c_cc[VINTR]
3031 ) { 3031 ) {
3032 /* Ctrl-C (usually) - stop gathering input */ 3032 /* Ctrl-C (usually) - stop gathering input */
3033#if ENABLE_PLATFORM_MINGW32
3034 if (state->flags & IGNORE_CTRL_C)
3035 break;
3036#endif
3033 command_len = 0; 3037 command_len = 0;
3034 break_out = -1; /* "do not append '\n'" */ 3038 break_out = -1; /* "do not append '\n'" */
3035 break; 3039 break;