5 Patch-ID: readline82-006
7 Bug-Reported-by: Tom de Vries <tdevries@suse.de>
9 Bug-Reference-URL: https://lists.gnu.org/archive/html/bug-readline/2022-09/msg00001.html
13 This is a variant of the same issue as the one fixed by patch 5. In this
14 case, the signal arrives and is pending before readline calls rl_getc().
15 When this happens, the pending signal will be handled by the loop, but may
16 alter or destroy some state that the callback uses. Readline needs to treat
17 this case the same way it would if a signal interrupts pselect/select, so
18 compound operations like searches and reading numeric arguments get cleaned
21 Patch (apply with `patch -p0'):
23 *** ../readline-8.2-patched/input.c 2022-12-22 16:15:48.000000000 -0500
24 --- input.c 2023-01-10 11:53:45.000000000 -0500
27 rl_getc (FILE *stream)
33 rl_getc (FILE *stream)
35 ! int result, ostate, osig;
43 + osig = _rl_caught_signal;
44 + ostate = rl_readline_state;
48 + #if defined (READLINE_CALLBACKS)
49 + /* Do signal handling post-processing here, but just in callback mode
50 + for right now because the signal cleanup can change some of the
51 + callback state, and we need to either let the application have a
52 + chance to react or abort some current operation that gets cleaned
53 + up by rl_callback_sigcleanup(). If not, we'll just run through the
55 + if (osig != 0 && (ostate & RL_STATE_CALLBACK))
56 + goto postproc_signal;
59 /* We know at this point that _rl_caught_signal == 0 */
66 + osig = _rl_caught_signal;
67 + ostate = rl_readline_state;
69 /* If the error that we received was EINTR, then try again,
70 this is simply an interrupted system call to read (). We allow
77 + /* POSIX says read(2)/pselect(2)/select(2) don't return EINTR for any
78 + reason other than being interrupted by a signal, so we can safely
79 + call the application's signal event hook. */
80 if (rl_signal_event_hook)
81 (*rl_signal_event_hook) ();
82 + #if defined (READLINE_CALLBACKS)
83 + else if (osig == SIGINT && (ostate & RL_STATE_CALLBACK) && (ostate & (RL_STATE_ISEARCH|RL_STATE_NSEARCH|RL_STATE_NUMERICARG)))
84 + /* just these cases for now */
85 + _rl_abort_internal ();
89 *** ../readline-8.2/patchlevel 2013-11-15 08:11:11.000000000 -0500
90 --- patchlevel 2014-03-21 08:28:40.000000000 -0400
93 # Do not edit -- exists only for use by patch
97 # Do not edit -- exists only for use by patch