fixes for SIGINT handling in asynchronous lists

This commit is contained in:
Chet Ramey
2023-01-17 13:31:46 -05:00
parent 0647e53bd1
commit a5d2617c7a
11 changed files with 767 additions and 1248 deletions
+27 -1
View File
@@ -811,7 +811,7 @@ rl_read_key (void)
int
rl_getc (FILE *stream)
{
int result;
int result, ostate, osig;
unsigned char c;
int fd;
#if defined (HAVE_PSELECT) || defined (HAVE_SELECT)
@@ -822,8 +822,22 @@ rl_getc (FILE *stream)
fd = fileno (stream);
while (1)
{
osig = _rl_caught_signal;
ostate = rl_readline_state;
RL_CHECK_SIGNALS ();
#if defined (READLINE_CALLBACKS)
/* Do signal handling post-processing here, but just in callback mode
for right now because the signal cleanup can change some of the
callback state, and we need to either let the application have a
chance to react or abort some current operation that gets cleaned
up by rl_callback_sigcleanup(). If not, we'll just run through the
loop again. */
if (osig != 0 && (ostate & RL_STATE_CALLBACK))
goto postproc_signal;
#endif
/* We know at this point that _rl_caught_signal == 0 */
#if defined (__MINGW32__)
@@ -887,6 +901,9 @@ rl_getc (FILE *stream)
/* fprintf(stderr, "rl_getc: result = %d errno = %d\n", result, errno); */
handle_error:
osig = _rl_caught_signal;
ostate = rl_readline_state;
/* If the error that we received was EINTR, then try again,
this is simply an interrupted system call to read (). We allow
the read to be interrupted if we caught SIGHUP, SIGTERM, or any
@@ -927,8 +944,17 @@ handle_error:
RL_CHECK_SIGNALS ();
#endif /* SIGALRM */
postproc_signal:
/* POSIX says read(2)/pselect(2)/select(2) don't return EINTR for any
reason other than being interrupted by a signal, so we can safely
call the application's signal event hook. */
if (rl_signal_event_hook)
(*rl_signal_event_hook) ();
#if defined (READLINE_CALLBACKS)
else if (osig == SIGINT && (ostate & RL_STATE_CALLBACK) && (ostate & (RL_STATE_ISEARCH|RL_STATE_NSEARCH|RL_STATE_NUMERICARG)))
/* just these cases for now */
_rl_abort_internal ();
#endif
}
}
+4 -2
View File
@@ -59,11 +59,13 @@ intrand32 (u_bits32_t last)
Park and Miller, Communications of the ACM, vol. 31, no. 10,
October 1988, p. 1195. Filtered through FreeBSD.
x(n+1) = 16807 * x(n) mod (m).
x(n+1) = 16807 * x(n) mod (m)
where 16807 == 7^5.
We split up the calculations to avoid overflow.
h = last / q; l = x - h * q; t = a * l - h * r
h = last / q; l = last % q; t = a * l - h * r
m = 2147483647, a = 16807, q = 127773, r = 2836
There are lots of other combinations of constants to use; look at